LoginSignup
34
35

More than 5 years have passed since last update.

iOS で Universal Static Library を作る方法

Last updated at Posted at 2015-01-06
  • 複数のアーキテクチャで作成されたStatic Library (*.aファイル)を一つにまとめることが出来ます。
  • 環境ごとに設定ファイルを変更して、Static Libraryを設定する必要がないので便利です。

作り方

  • Xcodeがインストールされている前提(確認済みの Xcodeのバージョンは 6.1.1になります)
  1. 実機用バイナリをコマンドラインでビルドします

    • 最近のトレンドに合わせて armv7, armv7s, arm64 としています
    xcodebuild -project Test.xcodeproj -sdk iphoneos -configuration Release -arch armv7 -arch armv7s -arch arm64 clean build
    
  2. シミュレータ用バイナリをコマンドラインでビルドします

    • 最近のトレンドに合わせて i386, x86_64 としています
    xcodebuild -project Test.xcodeproj -sdk iphonesimulator -configuration Release -arch i386 -arch x86_64 clean build
    
  3. 上記でビルドした a ファイルを結合

    xcrun -sdk iphoneos lipo -create build/Release-iphonesimulator/libTest.a build/Release-iphoneos/libTest.a -output build/Release-universallib/libTest.a
    
    

確認

  1. ただしく出来たか確認

    xcrun lipo -info build/Release-universallib/libTest.a
    
    

    この例だと

    Architectures in the fat file: build/Release-universallib/libTest.a are: armv7 armv7s i386 x86_64 arm64
    
    

    こんな感じで表示されるはず。

34
35
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
35