How to I import 3rd party frameworks into Xcode Playground?

There is currently no supported way to import your own framework or app code into a playground, short of pasting it into the playground editor. We’re aware that this is very desirable functionality, but as always we encourage people to “vote with bugreporter” at bugreport.apple.com

Right now, if you’re just trying to hide code for showing in an example, code folding in the editor might do the trick.

It is now possible to import your own frameworks into a playground. This provides a way to share code between your applications and playgrounds, which can both import your frameworks. To do this, your playground must be in the same workspace as the project that produces your framework. You must have already built your framework. If it is an iOS framework, it must be built for a 64-bit run destination (e.g. iPhone 5s). You must have an active scheme which builds at least one target (that target’s build location will be used in the framework search path for the playground). Your “Build Location” preference (in advanced “Locations” settings) should not be set to “Legacy”. If your framework is not a Swift framework the “Defines Module” build setting must be set to “Yes”. Once all these conditions are fulfilled, importing your framework will work in a playground.

Leave a Comment