1

I am trying to use SDWebImage in an IOS project.

I am following these instructions from their 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>

But I am getting this error:

SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc

I have tried to search for header search paths that some other answers say and I get these results:

Always search user paths -No
Header search paths
User header search paths

Must I set a value there? Or should I do anything else?

Another thing that i noticed in their demo is that: in their demo, in the frameworks folder they have imported the .xcodeproject of sdwebimageview and I have imported sdwebimageview.framework as the instructions say in the github.

Thanks!

Edit: my project is non-Arc.

I tried changing the other Linker flags from -ObjC to fobjc-arc but I still get the same error.

1)was that correct or should I change something else? 2) if I change my project from non-arc to arc what should I change? I only want to use that library so I prefer not change it.

In the .h file os SDWebImage it says:

#if !__has_feature(objc_arc)
#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif
ghostrider
  • 5,131
  • 14
  • 72
  • 120
  • Is your project non-ARC? – Shmidt Dec 29 '12 at 19:24
  • yes it is. i mean when creating it I remember not checking it. But since it is a long time where can I check it? – ghostrider Dec 29 '12 at 19:27
  • http://stackoverflow.com/questions/9018366/how-to-enable-disable-arc-in-an-xcode-project See last answer. – Shmidt Dec 29 '12 at 19:29
  • Actually, I can recommend you to install 3rd part code through Cocoapods, it'll save you hell a lot of time. http://www.raywenderlich.com/12139/introduction-to-cocoapods – Shmidt Dec 29 '12 at 19:32
  • @Flink yes it is a non-ARC project. So what to do? Enable it? and what things then I have to change in my code. I think that some of my structures should change, don't they? You can watch my edit, too. – ghostrider Dec 29 '12 at 19:36
  • If you don't want to enable it, just put fobjc-arc to file from SDWebImage in project target->Build cases->Compile sources – Shmidt Dec 29 '12 at 19:40
  • You may want to consider using AFNetworking instead. It is compatible with ARC and has a generally newer codebase. It also has a category on UIImage that allows for nearly the same image loading mechanism. – Kendall Helmstetter Gelner Dec 29 '12 at 21:26
  • @KendallHelmstetterGelner any link about that? – ghostrider Dec 30 '12 at 01:31

1 Answers1

4

This tutorial shows you how to set ARC or non-ARC per file in your project.

Unless you wanted to switch to ARC anyway, I suggest you leave your project as it is and just enable the -fobjc-arc option for the files in SDWebImage. Look at the tutorial above, the image in that shows you where to put the flags. (Their example uses -fno-objc-arc, which does the opposite, so just make sure you use -fobjc-arc. You type it in the same place.)

Amy Worrall
  • 16,250
  • 3
  • 42
  • 65