先日とある外部モジュールを利用しようと xCode へインポートしてコンパイルすると、
実機だと問題なくコンパイルされるのですが、シュミレータだと
下記のようなエラーが発生してビルドに失敗しました。
ld: warning: ignoring file /Users/….. , missing required architecture i386 in file /Users/….. (2 slices)
Undefined symbols for architecture i386:
 “_OBJC_CLASS_$_lib”, referenced from:
 objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ってことで、恐らく i386 に対応していないのではと思い、
iOS は Universal Binary なので、
対応しているアーキテクチャを調べると
$ lipo -detailed_info lib.a
Fat header in: lib.a
fat_magic 0xcafebabe
nfat_arch 2
architecture armv7
 cputype (12)
 cpusubtype cpusubtype (9)
 offset 48
 size 103696
 align 2^2 (4)
architecture (cputype (12) cpusubtype (11))
 cputype (12)
 cpusubtype cpusubtype (11)
 offset 103744
 size 103688
 align 2^2 (4)
ん、armv7s の名前が表示されないと思って、調べると
stackoverflow で
xcrun を使えと書いてあったので
$ xcrun -sdk iphoneos lipo -detailed_info lib.a
Fat header in: lib.a
fat_magic 0xcafebabe
nfat_arch 2
architecture armv7
 cputype (12)
 cpusubtype cpusubtype (9)
 offset 48
 size 103696
 align 2^2 (4)
architecture armv7s
 cputype (12)
 cpusubtype cpusubtype (11)
 offset 103744
 size 103688
 align 2^2 (4)
予想どおり、i386 がありませんでした。
ちなみに、GoogleAnalytics だと、
$ xcrun -sdk iphoneos lipo -detailed_info libGoogleAnalytics.a
Fat header in: libGoogleAnalytics.a
fat_magic 0xcafebabe
nfat_arch 3
architecture armv7
 cputype (12)
 cpusubtype cpusubtype (9)
 offset 68
 size 807344
 align 2^2 (4)
architecture armv7s
 cputype (12)
 cpusubtype cpusubtype (11)
 offset 807412
 size 807344
 align 2^2 (4)
architecture i386
 cputype CPU_TYPE_I386
 cpusubtype CPU_SUBTYPE_I386_ALL
 offset 1614756
 size 826920
 align 2^2 (4)
と表示され、
armv7、armv7s、i386
に対応されていることを確認できます。
  
  
  
  