1

Trying to install SDWebImage into my Swift project. I am using the following instructions (https://github.com/rs/SDWebImage):

  • 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

So I git clone --recursive the project from GitHub, I drag the .xcodeproj file into my project (since there is no SDWebImage.framework file as far as I can tell, and this has always worked for other frameworks), I complete the rest of the instructions:

  • 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

And then I add #import <SDWebImage/UIImageView+WebCache.h> in my bridging header. I build the project and I get: "SDWebImage/UIImageView+WebCache.h" not found. I've tried some variations on these steps and nothing seems to work. What am I doing wrong?

EDIT

Pretty sure this is happening because I'm not pulling in an SDWebImage.framework file, rather the .xcodeproj file. But I've downloaded from zip and cloned the repo, and there doesn't seem to be a .framework file in there...

UPDATE

So apparently I'm just supposed to download the compiled framework, which I found in another answer: https://stackoverflow.com/a/30545367/918065. Maybe? I have no clue. When I imported the .framework file my bridging header worked and recognized #import <SDWebImage/UIImageView+WebCache.h>, but it didn't recognize imageView.sd_.... So still workin on it.

Last compiled framework is 3.7.0 and you can find it in: https://github.com/rs/SDWebImage/releases

For easier access, the direct link to the framework is below: https://github.com/rs/SDWebImage/releases/download/3.6/SDWebImage-3.6.framework.zip

Community
  • 1
  • 1
Ryan Bobrowski
  • 2,641
  • 3
  • 31
  • 52

5 Answers5

4

import "SDWebImage/UIImageView+WebCache.h"

Community
  • 1
  • 1
Eddy Liu
  • 1,463
  • 9
  • 6
4

For me it helped when I remove SDWebImage from import. So I have this in my project-Bridging-Header.h:

#import "UIImageView+WebCache.h"

more information about iOS bridging header: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

sivi
  • 10,654
  • 2
  • 52
  • 51
Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
  • Didn't work for me. Did you import SDWebImage.xcodeproj or SDWebImage.framework into your project? Because I searched the folder and there is no .framework file, but I think that's the issue. – Ryan Bobrowski Jun 09 '15 at 17:32
  • Apparently I had to download the compiled framework...which I only found in another answer: http://stackoverflow.com/a/30545367/918065 – Ryan Bobrowski Jun 09 '15 at 17:39
  • It works for me. After updating cocoapods version from 0.39 to 1.0.1.beta.5 I have got an error "file not found" for the SDWebImage import in the bridging header. Changing the import to #import "UIImageView+WebCache.h" solves the issue. Thank you. – dzensik Jul 13 '16 at 12:14
1

I recommend using CocoaPods for dealing with dependencies. CocoaPods is a dependency manager that is designed to solve problems like these.

Follow the installation guide on their website: https://cocoapods.org

dennykim
  • 329
  • 1
  • 3
  • Yeh but I was having issues using that with some of my other frameworks so I decided to use the manual method and it's worked fine for the other 4 I've used so I want to see if I can stay consistent before I jump back to CocoaPods – Ryan Bobrowski Jun 08 '15 at 20:05
1

So nothing was working for me until I finally realized that you're supposed to use not the main SDWebImage folder, but the SDWebImage folder inside of that into the project. Dragging in the .xcodeproj file, the folder as a whole, or the .framework file didn't work. Importing that sub SDWebImage folder, and then utilizing Libor Zapletal's answer: #import "UIImageView+WebCache.h" is what finally got this thing working for me.

Ryan Bobrowski
  • 2,641
  • 3
  • 31
  • 52
0

This worked in my case:

  1. Add #import <SDWebImage/UIImageView+WebCache.h> in your bridging header
  2. In project Build Settings, set the path of the bridging header file in Objective-C Bridging Header. Ex. My Project/BridgingHeader.h
superm0
  • 963
  • 11
  • 19