Xcode4.2(iOS 5)以後啓用了ARC技術,雖然4.2以後版本仍然可以不開啓ARC,但是我們在建工程的時候有時爲了不想管理內存然後就啓用了ARC,但是再開發過程中需要用到第三開發類庫,而這些第三方類庫或是沒做更新而不支持ARC,然後編譯時就出現下列錯誤:
- '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,對於大部分第三方類庫來說都可以順利編譯通過