11

I'm trying to use SDWebImage in my iPhone app. I followed the step by step tutorial to install SDWebImage into my Xcode project.

When I try to build my app i'm getting the following error:

Lexical or Preprocessor Issue
'SDWebImage/UIImageView+WebCache.h' file not found 

Can somebody help me solve this issue?

mttrb
  • 8,297
  • 3
  • 35
  • 57
Lizard
  • 201
  • 1
  • 3
  • 8

10 Answers10

17

A much cleaner "install" of SDWebImage would be as follow:

  1. Drag SDWebImage folder from Finder into your Xcode's project
  2. On any .m file where you wish to use it add: #import "UIImageView+WebCache.h"

    (and any other SD component needed)

    instead of what you probably did: #import <SDWebImage/UIImageView+WebCache.h>

this does not require any project header manipulation and will work as is.

AmitP
  • 5,353
  • 4
  • 35
  • 27
10

It may happen that:

Unzipping this framework, the directory name may be the following: "SDWebImage-3.3.framework"

If you import the project this way, causes the error "framework SDWebImage not found" when compiling.

You need renaming, deleting "-3.3". Would be: "SDWebImage.framework"

Forcing the renamed from Xcode, causes a bug that close unexpectedly the IDE. Renames from Finder and add framework again.

I hope it's useful ...

enagra
  • 2,296
  • 1
  • 18
  • 19
6

I would not wish my worst enemy the frustration I had to go through to fix this problem because none of these solutions helped in my particular case. If your project compiled earlier, you came back to it and this error popped out of nowhere, chances are you've moved it to some new directory - so go to Build Settings > Search Paths > under Framework Search Paths delete the outdated path, create a new one and set it to "$(SRCROOT)" (without quotes) and change the default "non-recursive" to "recursive". I hope this spares someone the agony I endured.

user1433391
  • 277
  • 1
  • 3
  • 8
4

The @Lizard answer saved my day!

$(SRCROOT)/SDWebImage to Header Search Path

Just to be more specific, you have to add that configuration in your target and not in the project view.

rodchile
  • 181
  • 1
  • 9
  • I added to project, so that doesn't make any difference. However I had to use different path "$(SRCROOT)/../SDWebImage", since I don't have SDWebImage inside project folder, but one above (same level as project). – JOM Sep 19 '12 at 12:54
4

Using #import <SDWebImage/UIImageView+WebCache.h> fixed the issue for me as I was using Cocoapods as frameworks (use_frameworks!).

Feroz
  • 699
  • 5
  • 17
  • 25
3

Use

#import "UIImageView+WebCache.h"

instead of

#import <SDWebImage/UIImageView+WebCache.h>

Will solve it.

Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
Mann
  • 5,477
  • 6
  • 45
  • 57
3

I had .xcodeproj and .xcworkspace files and launched the code using .xcodeproj and got this error, but with .xcworkspace it worked fine

Alatoo
  • 171
  • 1
  • 4
2

Check if you have linked the file correctly and its in your bundle or not.

vishwa.deepak
  • 510
  • 4
  • 18
1

I was also getting this problem. Solution for me was to add SDWebImage.framework, instead of adding all files in my project. Here is the check list to make sure everything is setup as suggested by auther here.

Download and Add framework

Step 1: Download and unzip the lastest version here: https://github.com/rs/SDWebImage/wiki/Download-Complied-Framework

Step 2: Right-click on the project navigator and select "Add Files to "Your Project": In the dialog, select SDWebImage.framework, and 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"

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

#import <SDWebImage/UIImageView+WebCache.h>

It should build now without any problem.

Khawar
  • 9,151
  • 9
  • 46
  • 67
0

I got this error when I was removing some old unused Pods while keeping the XCode open. I have seen and read that you must keep XCode closed while doing any pod operation. Once pod operation is done, you should then reopen xcworkspace file and build.

Did the same closed the XCode, but also I removed the contents of Derived data just to start from a fresh page. It worked !

nr5
  • 4,228
  • 8
  • 42
  • 82