Reputation: 2234
I’m following the instructions for Importing Custom Frameworks into Playground, but I still keep getting "No such module” error. I have tried adding everything in the workspace; a project with just Framework target, project of Cocoa Application with the framework, and just the Framework. I also tried creating a playground in the Application where I imported the framework, I can even import it in other swift file without any problem; but I can’t seem to be able to import it in playground.
Can someone please tell me what I might be doing wrong?
Upvotes: 5
Views: 2009
Reputation: 357
I've spent for this more than 4 hours. But i've solved it for XCode 10.
You're unable to add any framework into the Playground if there's no target for it the Workspace where the Playground is. So as you using downloaded framework (so am i) — you're doomed to fail with it.
The workable manual could be found here (God bless this guy): https://www.pardel.dev/blog/3rd-party-frameworks-in-xcode-playgrounds
tldr: the easiest way is to:
Upvotes: 2
Reputation: 126
I would like to echo what Reid said:
Try building your framework target using a simulator! I had only built mine using the generic device which doesn't work for playgrounds!
If you've updated to Xcode 12, you also need to make the "Build Active Scheme" box is checked. Select your playground and go to the inspector. The checkbox will be under "Playground Settings"
Upvotes: 1
Reputation: 734
Try building your framework target using a simulator! I had only built mine using the generic device which doesn't work for playgrounds!
Upvotes: 3
Reputation: 2234
I solved my problem with a different solution than Michael Welch's. I had my Xcode derived data setting different than original. Go to Preferences > Locations > Derived Data > Advanced
and select Unique. This solved the framework not appearing in playground problem for me.
Upvotes: 0
Reputation: 1784
Did you ever get it to work? I figured out my issue. The code I was trying to import wasn't in a Framework Target. I had to add a new target to my project of type Cocoa Framework. Then include my source files in that framework, and then finally build that target. Then it worked.
Upvotes: 1