環境
現象
CocoaPodsを導入して、いざdebug-buildしたら記事タイトルのエラーが発生した。
以下はそのログである。
Undefined symbols for architecture i386: "_FBSDKAppEventParameterNameContentType", referenced from: -[MyViewController viewDidLoad] in MyViewController.o "_FBSDKAppEventParameterNameCurrency", referenced from: -[MyViewController viewDidLoad] in MyViewController.o "_OBJC_CLASS_$_FBSDKAppEvents", referenced from: objc-class-ref in MyAppDelegate.o objc-class-ref in MyViewController.o "_OBJC_CLASS_$_FBSDKApplicationDelegate", referenced from: objc-class-ref in MyAppDelegate.o "_OBJC_CLASS_$_FBSDKGraphRequest", referenced from: objc-class-ref in MyClass.o "_OBJC_CLASS_$_FBSDKLoginButton", referenced from: objc-class-ref in MyViewController.o ld: symbol(s) not found for architecture i386
結論
プロジェクト設定にて「Build Active Architecture Only」の項目が、Podsプロジェクトの設定と一致していなかったことが原因だった。
before
MyProject
- Build Settings
- Architectures
- Build Active Architecture Only
- Debug
- NO
- Release
- NO
- Debug
- Build Active Architecture Only
- Architectures
Pods
- Build Settings
- Architectures
- Build Active Architecture Only
- Debug
- YES
- Release
- NO
- Debug
- Build Active Architecture Only
- Architectures
after
MyProject
- Build Settings
- Architectures
- Build Active Architecture Only
- Debug
- YES
- Release
- NO
- Debug
- Build Active Architecture Only
- Architectures
Pods
- Build Settings
- Architectures
- Build Active Architecture Only
- Debug
- YES
- Release
- NO
- Debug
- Build Active Architecture Only
- Architectures
解決
Architecturesが「Standard architecures(armv7, arm64)」の状態で「Build Active Architecture Only」がYESの場合、 armv7, arm64だけを対象にビルドするっぽい。
Product>ArchiveではRelease設定を使うようにしているので、こちらでは「Build Active Architecture Only」をNOにしておこうと思う。