SDWebImage仅限ARC。为项目启用ARC或使用-fobjc-arc标志IOS

时间:2012-12-29 19:20:43

标签: ios xcode sdwebimage

我正在尝试在IOS项目中使用SDWebImage。

我正在遵循他们的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的.xcodeproject并且我已经导入了sdwebimageview.framework,如github中的说明所示。

谢谢!

编辑:我的项目是非Arc。

我尝试更改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

1 个答案:

答案 0 :(得分:4)

This tutorial向您展示如何在项目中为每个文件设置ARC或非ARC。

除非您想切换到ARC,否则我建议您保留项目原样,并为SDWebImage中的文件启用-fobjc-arc选项。看看上面的教程,其中的图像显示了放置标志的位置。 (他们的示例使用的是-fno-objc-arc,反之亦然,所以请确保使用-fobjc-arc。您可以在同一个地方输入它。)

相关问题