8/23/2023 0 Comments Xcode 12.5 release notes![]() In this case I just have the GridView class to add. We can now add those files we want to use in the playground to the framework target. ![]() Name the framework (I used GridViewUI) and change “Embed In Application” to “None”: To create a framework for our custom view, use “File > New > Target…” and choose the iOS “Framework” template: To get around that we can create a framework that we import into the playground. The playground is its own module and cannot see the application target module. ![]() Unfortunately we can’t just start using our project code and resources in the playground. The project navigator should have both the playground and project at the top level: Also make sure to select the option to add the playground to the workspace, keeping it at the top-level group:Īt this point you should have project, workspace and playground files in the root folder of the project: Adding a PlaygroundĬreate a new blank iOS playground with “File > New > Playground…” name and save it in the same location as the xcodeproj and xcworkspace files. Remember in future to open the workspace file not the project or playground. I named the workspace GridView after the project name and saved the xworkspace file in the same location as the xcodeproj file:Ĭlose the Xcode project and open the workspace. Starting from my basic Xcode project use “Save As Workspace…” from the File menu. The first step is to create an Xcode workspace to contain both the Xcode project and the playground. But what if I am not using Interface Builder? A playground live view can help fill that gap. I can make this view designable and inspectable so that I can preview and configure it directly in Interface Builder. The details are not interesting but here is the interface to the class:Ĭlass GridView : UIView Suppose I am using this project to develop a custom view that should draw a grid view with a configurable number of rows and columns. To show the idea I have a minimal Xcode project, named GridView, based on the single view application template. Starting with Xcode 12.5 you can also give your playgrounds access to your app types. See Creating Swift Packages in Xcode for details. Since the release of Xcode 11 I’ve switched to using the Swift package manager for code reuse. Three years later I still find using playgrounds for anything non-trivial to be frustrating. Note: I should warn you that I have pretty much given up on this approach. Getting it all setup the first time is a pain so for future reference here is my step-by-step guide. Unfortunately a playground does not automatically get access to the code and resources of a project. I especially like being able to use the playground live view to preview view and layout code without the need for Interface Builder. They also make great companions when added to your Xcode projects. Playgrounds are a great way to try out ideas but I have tended to use them standalone.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |