Last active
January 14, 2021 00:18
-
-
Save IanKeen/dfbe42fea3f5746e87aebac86d508f7e to your computer and use it in GitHub Desktop.
Getting playgrounds working in a project in xcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create a new xcode project | |
- You can skip this if you're adding the playground to an existing project | |
2. File > Save as workspace - save workspace in project folder | |
- You can skip this if you're adding the playground to an existing workspace | |
3. File > Playground - create new playground in project folder | |
4. Drag playground in at the _workspace_ level (root item, i.e. _not_ under the project) | |
5. Add a new Framework to your project (I usually name mine something like 'PlaygroundKit') | |
- You don't need to include tests | |
- Choose 'None' for Enbed in Application | |
6. Make all project files you want to be accessible to the playground are members of the new target | |
- this includes any new files you add | |
7. Build the new target | |
- You need to do this each time you make changes so they are available to the playground | |
8. `@testable import <PlaygroundTarget>` in playground and go nuts | |
- `@testable` can be omitted if everything you want available to the playground is explicitly `public` | |
NOTE: If you have any Cocoapods, make sure you add a target entry for <PlaygroundTarget> so they get access to the pods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Having said that - I'm almost certain that you can add a playground to a project in xcode10 and it 'just works' - I could have sworn I saw something on one of the talks at WWDC about this...