轉:在支援ARC工程中編譯不支援ARC的檔案

來源:互聯網
上載者:User

標籤:

轉: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
  1. ‘release‘ is unavailable: not available in automatic reference counting mode  
  2. ARC forbids explicit message send of ‘release‘  
  3. ‘autorelease‘ is unavailable: not available in automatic reference counting mode  
  4. ARC forbids explicit message send of ‘autorelease‘  
  5. ‘retain‘ is unavailable: not available in automatic reference counting mode  
  6. 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的檔案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.