標籤:
轉:http://blog.csdn.net/duxinfeng2010/article/details/8709697
實踐總結:-fno-objc-arc 設定 解決了 舊代碼中存在 release autorelease retain 等手動管理記憶體代碼的錯誤.
Xcode4.2(iOS 5)以後啟用了ARC技術,雖然4.2以後版本仍然可以不開啟ARC,但是我們在建工程的時候有時為了不想管理記憶體然後就啟用了ARC,但是再開發過程中需要用到第三開發類庫,而這些第三方類庫或是沒做更新而不支援ARC,然後編譯時間就出現下列錯誤:
[cpp] view plain copy
- ‘release‘ is unavailable: not available in automatic reference counting mode
- ARC forbids explicit message send of ‘release‘
- ‘autorelease‘ is unavailable: not available in automatic reference counting mode
- ARC forbids explicit message send of ‘autorelease‘
- ‘retain‘ is unavailable: not available in automatic reference counting mode
- ARC forbids explicit message send of ‘retain‘
解決辦法:
1.在targets->build phases中修改compiler Flags屬性,添加:-fobjc-arc,就可以讓舊的工程支援arc;
2.在targets->build phases中修改compiler Flags屬性,添加:-fno-objc-arc,就可以讓原來支援arc的工程不使用arc,對於大部分第三方類庫來說都可以順利編譯通過
轉:在支援ARC工程中編譯不支援ARC的檔案