Skip to content
June 1, 2012 / windperson

產生iOS Universal binary檔的static library方法

得使用“xcodebuild”和“lipo”這兩個commandline程式:

  1. 使用xcodebuild產生對應各種平台(iOS simulator, armv6, armv7)的static library (.a檔)command line切換到專案的.xcodeproj所在目錄下,執行xcodebuild:
    iOS simulator:

    xcodebuild -sdk iphonesimulator -configuration Debug
    

    armv6:

    xcodebuild -sdk iphoneos -arch armv6 -configuration Debug
    

    armv7:

    xcodebuild -sdk iphoneos -arch armv7 -configuration Debug
    

    就會在該專案設定的輸出目錄下產生.a檔

  2. 使用lipo合併各個平台的.a檔,例如
    lipo -create -output ./build/Debug/libMSODataLib-all.a /Debug-iphoneos/libMSODataLib.a /Debug-iphonesimulator/libMSODataLib.a
    

    就會在./build/Debug/目錄下產生把/Debug-iphoneos目錄跟/Debug-iphonesimulator
    目錄內的libMSODataLib.a檔合併的universal binary檔(或稱Fat binarylibMSODataLib-all.a

Note:用不同的編譯組態(debug, release)產生的.a檔無法用lipo合併。

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: