我正在嘗試在IOS項目中使用SDWebImage。SDWebImage僅ARC。爲項目打開ARC或使用-fobjc-arc標誌IOS
我下面從他們的github這些指令:
import the project as a static library.
Add the SDWebImage project to your project
Download and unzip the last version of the framework from the download page
Right-click on the project navigator and select "Add Files to "Your Project":
In the dialog, select SDWebImage.framework:
Check the "Copy items into destination group's folder (if needed)" checkbox
Add dependencies
In you application project app’s target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block:
Click the "+" button again and select the "ImageIO.framework", this is needed by the progressive download feature:
Add Linker Flag
Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag:
Import headers in your source files
In the source files where you need to use the library, import the header file:
#import <SDWebImage/UIImageView+WebCache.h>
但我收到此錯誤:
SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc
我曾嘗試搜索頭搜索路徑,其他一些答案,說和我得到這些結果:
Always search user paths -No
Header search paths
User header search paths
我必須在那裏設置一個值嗎?還是我應該做其他事情?
我在演示中注意到的另一件事是:在他們的演示中,在框架文件夾中,他們導入了sdwebimageview的.xcode項目,並且我已經按照github中的說明導入sdwebimageview.framework。
謝謝!
編輯:我的項目是非弧。
我試過改變other Linker flags from -ObjC to fobjc-arc
但我仍然得到相同的錯誤。
1)是否正確或我應該改變別的東西? 2)如果我將項目從非弧改爲弧,我應該改變什麼?我只想使用該庫,所以我不想改變它。
在.h文件OS SDWebImage它說:
#if !__has_feature(objc_arc)
#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif
您的項目是否爲非ARC? – Shmidt
是的。我的意思是在創建它時我記得沒有檢查它。但是,由於我有很長一段時間可以檢查它? – ghostrider
http://stackoverflow.com/questions/9018366/how-to-enable-disable-arc-in-an-xcode-project查看最後一個答案。 – Shmidt