问题
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:
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:
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?
回答1:
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.
回答2:
You are too close to correct answer. the only thing that you need to do - is
Rename "framework-test-01-universal" to "framework-test-01" (original name without suffix) - it's important!
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)?
来源:https://stackoverflow.com/questions/27136107/confused-about-different-procedures-for-creating-a-fat-static-library-in-xcode-6