【iOS】SDK開発で外部フレームワークを「内包しない」ための設定と検証方法
本記事は、『iOS Advent Calendar 2025』16日目の記事です。
はじめに
自社SDKを開発していて、外部のthird party frameworkを利用する必要がありました。
ただし要件として「SDKに外部フレームワークを内包しない」というものがあり、この実現方法と検証方法に苦労しました。
モバイルエンジニア歴の長いベテランの方も「SDK側とアプリ側の構成をどうすればいいのか」で悩んだ内容だったので、同じ課題に直面している方の参考になればと思い記事にしました。
この記事で解決できること
✅ SDK開発時の「Do Not Embed」と「Embed & Sign」の正しい使い分け
✅ SDK側とアプリ側の構成の理解
✅ 外部フレームワークが内包されていないことの検証方法
✅ CFBundleIdentifier Collisionエラーの回避方法
対象読者
- iOSアプリ開発者(SDKを利用する側)
- これからSDK開発を始める人
- フレームワークの依存関係で困っている人
結論(先に知りたい方向け)
| 対象 | Embed設定 |
|---|---|
| SDK側(外部フレームワークを参照) | Do Not Embed |
| アプリ側(SDK+外部フレームワークを利用) | Embed & Sign |
MySDK.framework (SDK)
└── ExternalSDKへの参照のみ ← Do Not Embed(内包しない)
MyApp.app (アプリ)
├── MySDK.framework ← Embed & Sign
└── ExternalSDK.framework ← Embed & Sign
参考: iOSDC Japan 2019 - ライブラリのインポートとリンクの仕組み完全解説 by Kishikawa Katsumi
SDK開発でよくある混乱
「どこで何をEmbedすればいいの?」
SDK開発の経験がないと、以下のような構成で混乱しがちです。
MyProject/
├── MySDK/ ← フレームワークプロジェクト
│ ├── import ExternalSDK ← コード内でimport
│ └── ExternalSDK → ??? ← ここの設定は?
│
└── MyApp/ ← サンプルアプリ
├── MySDK.framework ← ここの設定は?
└── ExternalSDK.xcframework ← ここの設定は?
答え:役割を分けて考える
MyProject/
├── MySDK/ ← フレームワークプロジェクト
│ ├── import ExternalSDK ← コード内でimport(利用する)
│ └── ExternalSDK.xcframework → Do Not Embed ← リンクのみ(内包しない)
│
└── MyApp/ ← サンプルアプリ
├── MySDK.framework → Embed & Sign ← 内包する
└── ExternalSDK.xcframework → Embed & Sign ← 内包する
なぜこの構成なのか?
| レイヤー | 役割 | Embed設定 |
|---|---|---|
| SDK | 外部フレームワークを「使う」だけ | Do Not Embed |
| アプリ | 実行時に必要なものを「持つ」 | Embed & Sign |
ポイント:
- SDKは「外部フレームワークのAPIを呼び出す権利」だけを持つ
- 実際のバイナリはアプリ側が持つ
- 実行時にアプリ内のフレームワークが使われる
Embed設定の種類
Xcodeでフレームワークを追加する際、「Embed」の設定には3種類あります。
| 設定 | 動作 | 用途 |
|---|---|---|
| Do Not Embed | リンクのみ。バイナリに含めない | SDK側で外部フレームワークを参照する場合 |
| Embed & Sign | バイナリに含めて署名する | アプリ側でフレームワークを利用する場合 |
| Embed Without Signing | バイナリに含めるが署名しない | 特殊なケース(ほぼ使わない) |
参考
Do not Embed
With the “Do Not Embed” choice you are literally saying: please don’t pack all the contents of this framework with the main application.
This implies that the final application package will not contain a folder called (by default) Frameworks with all the framework code.
「Do not Embed」を選択すると、文字通り「このframeworkの内容をmain applicationに同梱しないでください」と指示することになります。
これにより、最終的なapplication packageには(デフォルトでは)Frameworks という名前のfolderが含まれず、frameworkのcode全体が格納されません。
なぜ「Do Not Embed」が必要なのか?
SDK側でも「Embed & Sign」にしてしまうと、フレームワークが二重に含まれる問題が発生します。
❌ 間違った構成(両方でEmbed & Signした場合)
MyApp.app
├── MySDK.framework
│ └── ExternalSDK.framework ← SDKに内包(1つ目)
└── ExternalSDK.framework ← アプリにも含まれる(2つ目)
この状態でApp Store Connectにアップロードすると、以下のエラーが発生します:
ERROR ITMS-90685: "CFBundleIdentifier Collision.
There is more than one bundle with the CFBundleIdentifier value
'com.example.ExternalSDK' under the application MyApp.app"
参考
In a modularized application that uses multiple nested frameworks, when trying to publish the app to TestFlight, if we get the error stating ERROR ITMS-90685: "CFBundleIdentifier Collision.
There is more than one bundle with the CFBundleIdentifier value com.example.project under the application Project.app" means some framework has embedded another framework which the main app is also embedding.
The fix here is to go to the all other frameworks and choose not to embed any frameworks and only Embed & Sign in the main app.
複数のネストされたフレームワークを使用するモジュール化されたアプリケーションで、TestFlight にアプリを公開しようとすると、次のエラーが発生する場合があります。
ERROR ITMS-90685: "CFBundleIdentifier Collision.
アプリケーションProject.appの下で、CFBundleIdentifier値com.example.projectを持つバンドルが複数存在します」というエラーが発生した場合、これはメインアプリケーションも組み込んでいるframeworkを、別のframeworkが組み込んでいることを意味します。
この場合の修正方法は、他のすべてのframeworkで「Do Not Embed」を選択し、メインアプリケーションのみを「Embed & Sign」することです。
正しい設定手順
1. SDK側の設定(Do Not Embed)
手順:
- XcodeでSDKプロジェクトを開く
- TARGETSからSDKのターゲットを選択
- 「General」タブを開く
- 「Frameworks, Libraries, and Embedded Content」セクションを確認
- 外部フレームワークのEmbed設定を「Do Not Embed」に変更

Frameworks, Libraries, and Embedded Content
┌─────────────────────────────┬──────────────┐
│ Name │ Embed │
├─────────────────────────────┼──────────────┤
│ ExternalSDK.xcframework │ Do Not Embed │ ← これ
└─────────────────────────────┴──────────────┘
2. アプリ側の設定(Embed & Sign)
手順:
- Xcodeでアプリプロジェクトを開く
- TARGETSからアプリのターゲットを選択
- 「General」タブを開く
- 「Frameworks, Libraries, and Embedded Content」セクションを確認
- SDK・外部フレームワーク両方を「Embed & Sign」に設定

Frameworks, Libraries, and Embedded Content
┌─────────────────────────────┬──────────────┐
│ Name │ Embed │
├─────────────────────────────┼──────────────┤
│ MySDK.xcframework │ Embed & Sign │
│ ExternalSDK.xcframework │ Embed & Sign │
└─────────────────────────────┴──────────────┘
内包されていないことの検証方法
「Do Not Embed」に設定したつもりでも、本当に内包されていないか不安ですよね。
nmコマンドを使って検証できます。
nmコマンドとは
nmはバイナリに含まれるシンボル(関数名、クラス名など)を一覧表示するコマンドです。
macOS/Xcode に標準搭載されているツールで、フレームワークやライブラリにどのようなシンボルが含まれているかを確認できます。
参考:
To view the symbols exported by your application, use the nm tool.
This tool reads an executable’s symbol table and displays the symbol information you request.
You can view all symbols or just the symbols from a specific segment of your executable code.
For example, to display only the externally available global symbols, you would specify the -g option on the command line.
アプリケーションがエクスポートしたシンボルを表示するには、nm ツールを使用します。
このツールは実行可能ファイルのシンボルテーブルを読み取り、要求したシンボル情報を表示します。
すべてのシンボルを表示することも、実行可能コードの特定のセグメントからのシンボルのみを表示することもできます。
たとえば、外部から利用可能なグローバルシンボルのみを表示するには、コマンドラインで -g オプションを指定します。
nmコマンドのオプション詳細
| タイプ | 意味 |
|---|---|
| T | コード/関数(text section) |
| S | その他のセクション |
| U | 未定義(外部参照) |
| D | データ |
※ 大文字はグローバル(外部公開)、小文字はローカル
参考:
↓それぞれのシンボルがどのような意味を表しているのか記載しているサイト。
Each symbol name is preceded by its value (blanks if undefined).
Unless the -m option is specified, this value is followed by one of the following characters, representing the symbol type:
U (undefined),
A (absolute),
T (text section symbol),
D (data section symbol),
B (bss section symbol),
C (common symbol), - (for debugger symbol table entries; see -a below),
S (symbol in a section other than those above), or
I (indirect symbol).
If the symbol is local (non-external), the symbol's type is instead represented by the corresponding lowercase letter.
A lower case u in a dynamic shared library indicates a undefined reference to a private external in another module in the same library.
検証手順
1. ビルドしたSDKフレームワークの場所を確認
find ~/Library/Developer/Xcode/DerivedData -name "MySDK.framework" -type d 2>/dev/null
2. nmコマンドでシンボルを確認
nm -gU "/path/to/MySDK.framework/MySDK" | grep -i "external"
結果の見方
✅ 正しい状態(内包されていない)
0000000000003368 T _$s5MySDK19ExternalSDKBridgeC21onSessionTagDetect...
0000000000003b28 T _$s5MySDK19ExternalSDKBridgeC23onSessionErrorDetect...
表示されるのは MySDK.ExternalSDKBridge(自分が書いたブリッジクラス)のシンボルのみ。
ExternalSDK.SomeController のようなシンボルが表示されなければOKです。
❌ 問題のある状態(内包されている)
0000000000001234 T _$s11ExternalSDK14SomeControllerC...
0000000000005678 T _$s11ExternalSDK12AnotherClassC...
ExternalSDK本体のシンボルが表示される場合、内包されてしまっています。
注意点
1. Xcodeが勝手にEmbed設定を変更する
フレームワークを追加した際、Xcodeがデフォルトで「Embed & Sign」にすることがあります。
追加後は必ず設定を確認する必要があります。
2. Build Phasesにも注意
「General」タブだけでなく、「Build Phases」→「Embed Frameworks」セクションも確認してください。ここに表示されていると内包されます。
Build Phases
├── Dependencies
├── Compile Sources
├── Link Binary With Libraries ← Do Not Embedでもここには表示される
└── Embed Frameworks ← ここに表示されると内包される

ポイント:
- 「Link Binary With Libraries」に表示 → リンクされている(OK)
- 「Embed Frameworks」に表示 → 内包されている(SDK側ではNG)
Q&A
Q1. SDK側で「Do Not Embed」にしたら、SDKから外部フレームワークの機能を呼び出せなくなりませんか?
A. 呼び出せます。
「Do Not Embed」はあくまで「バイナリに含めない」という設定です。
コンパイル時にはリンクされるので、SDKのコードから外部フレームワークのAPIを呼び出すことは可能です。
実行時には、アプリ側でEmbed & Signされた外部フレームワークが使用されます。
原文を見る
Embedding a framework that mach-o-type is a dynamic library you are assuring that all the files of that framework will be available in the final bundle of the app.
When the app try to resolve the external symbols that are not inside the main app code it will find them inside the app bundle in the framework folder.
As explained above, this could affect seriously your startup time so be careful with dynamic linking.
mach-o-typeのframeworkを動的libraryとして組み込むことで、そのframeworkの全ファイルがアプリの最終バンドル内で利用可能になることを保証します。
アプリがメインコード内に存在しない外部シンボルを解決しようとする際、それらをアプリバンドル内のフレームワークフォルダ内で見つけ出します。
前述の通り、これは起動時間に深刻な影響を与える可能性があるため、動的リンクには注意が必要です。
Q2. アプリ側で外部フレームワークをEmbedし忘れるとどうなりますか?
A. 実行時にクラッシュします。
下記エラーが出たら、アプリ側で外部フレームワークを「Embed & Sign」し忘れています。
Configuration Errors
The following errors are caused by a project configuration that embeds a framework built for a build configuration that is different from the build configuration for the app
Dyld Error Message:
Dyld Message: Library not loaded: @rpath/<YourFrameworkName>.framework/<YourFrameworkName>
Referenced from: <PathToYourApp>
Reason: image not found
まとめ
| ポイント | 内容 |
|---|---|
| SDK側の設定 | Do Not Embed(リンクのみ) |
| アプリ側の設定 | Embed & Sign(SDK+外部framework両方) |
| 検証方法 |
nm -gUコマンドでシンボル確認 |
構成の覚え方
「使う側」は Do Not Embed(借りるだけ)
「持つ側」は Embed & Sign(実体を持つ)
SDK開発は通常のアプリ開発とは異なる考慮が必要です。
この記事が同じ課題に直面している方の参考になれば幸いです。
Discussion