Search code examples
cocoacocoa-touchios8xcode6ios-universal-framework

confused about different procedures for creating a fat static library in Xcode 6


I'm a little confused about information I am finding about how to create a universal framework using the latest Xcode 6 and iOS 8 environment. For instance, this answer includes the following:

If you need to create universal static library that runs on both simulator and devices, then general steps are:

 1. Build library for simulator  
 2. Build library for device  
 3. Combine them using lipo

lipo -create -output "framework-test-01-universal" "Debug-iphonesimulator/framework-test-01.framework/framework-test-01" "Debug-iphoneos/framework-test-01.framework/framework-test-01"  Note that framework-test-01 is my framework project name.

One of my coworkers followed those instructions and build an executable. Well, I don't think that is what I am looking for. It contains a structure that looks like this:

enter image description here

Later on, another answer here talks about creating an Aggregate Target with a Build Phase Run Script, which is what I am familiar with in the previous version of Xcode. When I use that process I receive what I am expecting. A folder structure as follows:

enter image description here

Can someone please help clear up this confusion we are having?

What is the difference between the two?

I mean, is the first procedure for creating an application that can run on both the simulator and the device, while the second is for creating a fat static library?


Solution

  • The important distinction is between the library and the framework. The framework is just a specific folder structure that contains your library and headers.

    lipo combines libraries. So the instructions have a sample execution that refers to the library inside of a framework you have already built (once for iphoneos, once for the simulator). The only difference between the frameworks is the library, so by using lipo to combine the libraries you get a fat (or fatter) library with all supported frameworks.

    That first linked answer tells you how to create both a framework and an app. Only worry about the framework part. Build the framework twice with different targets (an iOS device and a simulator). Make sure that you 'Build Active Architecture Only' is set to 'No'. You'll probably want to build for release rather than debug, but it depends on your specific needs.