你不想得到rid這個錯誤,你想要修復吧。
這裏的問題是,你要鏈接一個模擬器版本的庫到設備構建應用程序的。模擬器需要i386架構中的庫,而設備需要armv6或armv7架構中的東西。
所以這裏的解決方案是鏈接正確版本的庫。
我通常所做的就是將它們合併成一個庫,並讓鏈接器爲我選擇合適的版本。下面是你在終端做什麼:
$ cd /path/to/my/libraries
$ ls
libMyLibrary-Device.a
libMyLibrary-Simulator.a
$ file libMyLibrary-Device.a
libMyLibrary-Device.a: Mach-O universal binary with 2 architectures
libMyLibrary-Device.a (for architecture armv6): current ar archive random library
libMyLibrary-Device.a (for architecture armv7): current ar archive random library
$ file libMyLibrary-Simulator.a
libMyLibrary-Simulator.a: Mach-O universal binary with 1 architecture
libMyLibrary-Simulator.a (for architecture i386): current ar archive random library
$ lipo -create -output libMyLibrary.a libMyLibrary-Device.a libMyLibrary-Simulator.a
$ ls
libMyLibrary-Device.a
libMyLibrary-Simulator.a
libMyLibrary.a
$ file libMyLibrary.a
libMyLibrary.a: Mach-O universal binary with 3 architectures
libMyLibrary.a (for architecture armv6): current ar archive random library
libMyLibrary.a (for architecture armv7): current ar archive random library
libMyLibrary.a (for architecture i386): current ar archive random library
然後你只需鏈接libMyLibrary
而不是設備或模擬器版本,鏈接器將做正確的事情。
這正是我所期待的。非常感謝! – 2011-02-07 13:38:13
謝謝。當你爲iPhone模擬器建立在哪個位置是靜態庫,但? – huggie 2012-04-02 04:25:43