3

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?

Community
  • 1
  • 1
Patricia
  • 5,019
  • 14
  • 72
  • 152

2 Answers2

3

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.

Ben Flynn
  • 18,524
  • 20
  • 97
  • 142
  • OK. This is helpful. But I need to be clear on a few things. So if we Build library for simulator and Build library for device then use the lipo command at the command line that should really be the same as using the Aggregate Target with a Build Phase Run Script? Meaning that both processes work the same (building library for simulator and another for device and manually running the lipo command is essentially the same as creating the Aggregate Target using a Build Phase Run Script). 'Build Active Architecture Only' is set to 'No'. – Patricia Nov 25 '14 at 22:10
  • 1
    An "Aggregate" target just lets you build several targets at the same time. I use one (which I haven't updated in some time, so there might be features that I'm missing) in a convoluted way -- I use it to run xcodebuild to build for the simulator and then the devices and then run lipo and do some copying. I'm pretty certain you'll need to run lipo after building. – Ben Flynn Nov 25 '14 at 22:41
  • 1
    I think I understand. You can do the process manually or you can use an Aggregate Target with a Build Phase Run Script. Both need to run lipo. – Patricia Nov 25 '14 at 22:47
1

You are too close to correct answer. the only thing that you need to do - is

  1. Rename "framework-test-01-universal" to "framework-test-01" (original name without suffix) - it's important!

  2. Go into one of the *.frameworks (in Debug-ios folder, for example) and replace the library with your new "framework-test-01" library.

Thats it! ./Debug-ios/framework-test-01.framework - is ready-to-use fat binary! You can import it to your project!

Check me answer here for more details: How to export "fat" Cocoa Touch Framework (for Simulator and Device)?

Community
  • 1
  • 1
skywinder
  • 21,291
  • 15
  • 93
  • 123
  • I'm neck deep in C++ and Boost right now but I'll take a look and see if I can get the framework working using your instructions. If it works, then you should get the check for the correct answer. Thank you! – Patricia Apr 15 '15 at 14:57