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,对于大部分第三方类库来说都可以顺利编译通过

 

在支持ARC工程中编译不支持ARC的文件_ARC