问题
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?
回答1:
Try building your framework target using a simulator! I had only built mine using the generic device which doesn't work for playgrounds!
回答2:
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.
回答3:
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://medium.com/@pardel/using-3rd-party-frameworks-in-xcode-10-playgrounds-97aa0c3f56e0
tldr: the easiest way is to:
- Download 3rd party framework sources.
- Open *.xcodeproj
- Add Playground to the Project.
- Build project for any iOS simulator by cmd+b (have no idea how to use any macOS frameworks yet).
- And it should work (at least it does for me).
回答4:
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.
来源:https://stackoverflow.com/questions/29365604/error-importing-framework-in-playground