Error importing framework in Playground

谁都会走 提交于 2019-12-13 14:46:11

问题


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:

  1. Download 3rd party framework sources.
  2. Open *.xcodeproj
  3. Add Playground to the Project.
  4. Build project for any iOS simulator by cmd+b (have no idea how to use any macOS frameworks yet).
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!