Nate Murray Nate Murray - 2 months ago 49
Swift Question

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

How do I import 3rd part frameworks into Xcode Playground?

Swift Playground obviously has a framework import mechanism because we can import

Cocoa
,
SpriteKit
, and in an OSX Playground,
XCPlayground
(
XCPlayground
seems missing from iOS, oddly)

What I'd really like to do is hide code from my playground and be able to show a minimal example. Any thoughts on how to load a Framework into Swift playground?

See also:



(This question is different because the request is to use a framework in Playground rather than simply regular
swift
files)

Answer

Edited: As of Beta5 this is now supported when the playground is part of the workspace that builds the framework as a target. There are more details on the Apple dev forums site, but hopefully @Rick Ballard will add them to his answer here and that should becoke the definitive answer for this question.

Don't do the below anymore!


For the short term, while there's no supported solution, if you're producing a Module/Framework you can copy it into the SDKs System/Library/Frameworks directory and then just import <#Module#> the same way as you import system Frameworks.

For an OS X Playground: /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks

And for iOS: /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/

But before you do that... go file a radar as @Rick says in his answer.