iOS9: Using dynamic framework with Simulator and Device

孤人 提交于 2019-12-21 04:34:12

问题


I created a dynamic cocoa framework that I would like to use across my apps.

After I build the framework for an actual device, I bring it over to an app. I can only run the app on that device.

When I try to run it on a simulator, framework files are not recognized. I get error messages: 'ViewController' is unavailable: cannot find swift for declaration for this class

I tried building the framework for an iPhone 6 simulator and running the app on an iPhone 6 simulator, but the same problem persists.

How can I create/build a single framework that I can bring into any app and be able to use it on a simulator and a device?


回答1:


What you are looking to do is build a "Universal Framework". I answered a question about this here, but I will summarize the main points for you:

The reason you aren't able to compile it because the simulator runs on a different architecture than a device. Also, different iPhone models run on different architectures. You can look at this image to see what devices run on each architecture. The simulator runs on the mac arcs, which are i386 and x86. What you need to do is build for each architecture, then merge them all together through a process called "lipo".

To do this you want to set "Build Active Architectures" to NO. Then you should build your framework for a "Generic iOS Device". Then if you copy the build script from my first link, and put it as an aggregate target, this will build out each architecture and merge them into what will be your final product. This is called a FAT framework, and you can then run the command "lipo -info" in the terminal and you will see that your framework contains all architectures, which is what you want.



来源:https://stackoverflow.com/questions/35871571/ios9-using-dynamic-framework-with-simulator-and-device

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