Re: build two static libraries with one scheme/target
Re: build two static libraries with one scheme/target
- Subject: Re: build two static libraries with one scheme/target
- From: Jens Alfke <email@hidden>
- Date: Mon, 08 Aug 2011 10:55:42 -0700
On Aug 8, 2011, at 8:12 AM, Michael Hanna wrote:
> In xcode 4.0.2, I want to build two static library products(one i386, one ARM) from a single target. I can do that by changing the scheme but I want to automate that. Is this getting a scheme to build for a particular arch?
This is IMHO a huge mess in Xcode. Apple doesn’t seem to have considered at all that developers might want to create reusable frameworks for iOS, that should work both on devices and in the simulator, just like Apple’s frameworks (albeit statically linked.) So there’s no way to build both architectures at once, there’s no way to build a “fat” static library, and there’s no support for packaging a static library in a framework.
All of which we finally managed to figure out for building Couchbase Mobile, but at the cost of a lot of hair-pulling and probably a solid week of my time spent cursing in front of the project build settings UI in Xcode 4. The only thing worse would have been trying to do it in Xcode 3. :-p
The key bit of rocket-science is how to build both architectures at once in one build. I finally found a script that does it here:
http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4/3647187#3647187
It’s a bit of a hack in that it recursively invokes ‘xcodebuild’, but it works.
After that, using the lipo tool to merge the two into one fat library is easy, as it creating a bundle with the ‘.framework’ extension to make a real live framework with headers inside that’s easy for other projects to use.
If you want to look at an example, albeit a complicated one:
https://github.com/couchbaselabs/iOS-Couchbase/
the stuff that does this is in Couchbase.xcodeproj, in the ‘Couchbase’ and ‘Couchbase Framework’ target settings.
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden