2011-10-17 46 views
10

當我嘗試運行我在的iOS 4.3模擬器(4.2的Xcode)應用程序,我崩潰的時候,我打@autoreleasepool {},有:有條件連接的@autoreleasepool

dyld: lazy symbol binding failed: Symbol not found: _objc_autoreleasePoolPush 

我環顧四周,我請參閱解決方法是添加libarclite_iphoneos.a。這個模擬器也有一個版本,如libarclite_iphonesimulator.a

我需要兩個庫添加到我的項目,使其在模擬器上和硬件都運行。但無論我建立什麼,它都會抱怨另一個庫用於不受支持的體系結構。

例如,用於建設模擬器:

ld: warning: ignoring file /Developer-4.2/Platforms/iPhoneOS.platform/ 
Developer/usr/lib/arc/libarclite_iphoneos.a, missing required architecture 
i386 in file 

如何同時固定這兩個?或者我現在應該堅持舊的NSAutoreleasePool語法?

+0

似乎是鐺問題,因爲在建的設置改變編譯器LLVM-GCC-4.2解決了該問題對我來說 –

+0

我認爲它修復了自;我幾個月沒有遇到過它。 –

回答

10

喜歡乾淨,整潔文件夾中的試驗後,復位iPhone模擬器,甚至重新啓動,我改變了IPHONE_DEPLYMENT_TARGET目標構建從iOS的5.0放下至iOS 4.2。 工作。

+0

我會重新測試,也許它已被修復。謝謝。 –

+0

@amosel:你使用的是哪個xcode版本? 4.2。或4.2.1? –

+0

@JohannesRudolph我使用4.2生成4D199 – amosel

1

可以使用其它鏈接器標記構建設置在鏈接到該庫,並專門基於它是否是「任何iOS版」或「任何iPhone模擬器」的值。

+0

這看起來應該可以工作。我在做這個工作。 :) –

+1

@StevenFisher:我很神祕,爲什麼這是必要的。當您的部署目標設置在5.0之前時,Clang應該在適當的庫中爲您鏈接。 –

+0

好點。我做了一些進一步的測試。它看起來只是在編譯模擬器時出現問題。編譯器件時,它會自動包含器件。我不得不添加'$ {} PLATFORM_DEVELOPER_USR_DIR/lib中/ arc'爲'LIBRARY_SEARCH_PATHS'和'-larclite_iphonesimulator'到'OTHER_LDFLAGS [SDK = iphonesimulator *] [ARCH = *]',但有沒有必要做了一個設定iOS硬件。所以這幾乎肯定是一個錯誤。 –

0

您也可以合併兩個靜態庫到一個通用庫。轉到終端,並說,說(在終端中)

file /where/you/put/it/libarclite_universal.a 

lipo -create -output /where/you/want/it/libarclite_universal.a /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/arc/libarclite_iphoneos.a /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/arc/libarclite_iphonesimulator.a 

可以驗證生成的文件它應該輸出:

libarclite_universal.a: Mach-O universal binary with 3 architectures 
libarclite_universal.a (for architecture i386):current ar archive random library 
libarclite_universal.a (for architecture armv6):current ar archive random library 
libarclite_universal.a (for architecture armv7):current ar archive random library 

由於這LIB靜態鏈接,您的最終應用程序不會因爲包含的SIM卡庫而增長,因爲只有您的應用程序需要的任何內容纔會鏈接到您的最終應用程序中。