Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS9: Using dynamic framework with Simulator and Device

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?

like image 726
user1107173 Avatar asked Mar 08 '16 15:03

user1107173


1 Answers

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.

like image 150
arc4randall Avatar answered Sep 21 '22 20:09

arc4randall