开发者

I want to know how to make a makefile for iOS "fat" library

开发者 https://www.devze.com 2023-04-02 18:26 出处:网络
I want to create a (non-xcode) makefile to create a fat library (emulator + device(s)) that can be imported into an XCode project using a makefile that calls the basic command line to开发者_如何学运维

I want to create a (non-xcode) makefile to create a fat library (emulator + device(s)) that can be imported into an XCode project using a makefile that calls the basic command line to开发者_如何学运维ols directly (not running XCODE from the command line, but the MAC Gcc and it's related utilities) - this is for .m, .mm, .c, and .cpp source files.

Ideal would be to find an example that works for a simple library (not by calling a makefile generator that makes an almost non human readable makefile)

anyway anyone know of such a thing or appropriate mechanism for doing the same?

Also an ability to extract the complier flags from an XCode project would be real handy :)

The purpose is I want to add a module to my cross platform libraries so I can integrate them into an iOS project.

Thanks!!


You can extract the compiler flags by viewing the build details or, more simply, running xcodebuild from the command line.

To create a fat binary, you either take advantage of the compiler toolchain's built-in support on the Mac OS X platform by passing multiple -arch arguments, like so:

clang -arch i386 -arch x86_64 -framework Foundation simple.m -o simple

Alternatively, you build the binary once for each desired architecture, then wrap all those binaries into a single fat binary using lipo. This is handy when working with ported Unix software; just change the build result directory each time, then smash them all together after building with lipo. Assuming you have simple-i386 and simple-x86_64, you would then do:

lipo simple-i386 simple-x86_64 -create -output simple

This would create a fat binary named simple containing simple-i386 and simple-x86_64.


Ok - I found this which is a great HOWTO o building a fat library using XCODE that outlines the process and how to create the projects

http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/

being a newbie to XCode and iOS development I had to discover a few things.

  • you can view the actual command line output of a build to see what the gcc flags are. View->Navigators->Log - then control click on the messages list to "expand all Transcripts" to see what stdout and stderr from the chosen build's build output.

  • You can execute an "external build tool" with your .bashrc and .bash_profile environment settings by making the command and arguments a login shell: "bash --login -c 'mybuildtool [my tools args] $(ACTION)', and thus bypass having to deal with the hard to maintain MacOSX launchd settings etc. this works for things like using ruby and rake as well as make etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号