LoginSignup
34
25

More than 5 years have passed since last update.

[iOS]bitcode対応のlibrary/frameworkを作成する

Posted at

はじめに

OS、デバイスに最適化する機能 App Thinning が実装されていくとのことで、ライブラリの bitcode 対応の必要があった為、簡単ですがまとめました。

なお、現時点(2016/02/10)では iOS の bitcode 対応は任意です。
申請時のバイナリアップロードの際にチェックボックスがあるので、対応している場合はチェックをして提出します。

Xcode 7.2.1

ビルド設定

Build Settings で Custom Compiler Flags 項目の Other C Flags に -fembed-bitcode を指定してビルドする。

スクリーンショット 2016-02-10 5.06.27.png

コマンドラインで直接指定する場合は、

xcodebuild OTHER_CFLAGS="-fembed-bitcode"

バイナリの bitcode 確認

otool を利用してバイナリの内容で bitcode セクションを調べ、size を確認します。

$ otool -l [library file]

以下の例は、複数アーキテクチャを含んだバイナリのため -arch でアーキテクチャを指定して確認しています。
また、出力結果の一部抜粋になりますので、grep なり more なりで必要箇所を確認してください。

  • bitcode セクションは含まれているが対応ビルドではない場合の例
$ otool -arch armv7 -l libSample.a
Section
  sectname __bitcode
   segname __LLVM
      addr 0x00016804
      size 0x00000001
    offset 95420
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
  • bitcode 対応ビルドの例
$ otool -arch armv7 -l libSample.a
Section
  sectname __bitcode
   segname __LLVM
      addr 0x00017cb0
      size 0x000314f0
    offset 100712
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0

以上

34
25
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
25