Search code examples
iosxcodeuitableviewswiftsdwebimage

How to import and use SDWebImage in swift xcode 6.3.1


Im new to Swift and now making a project that includes showing many photos from the web and I understand that I need to use SDWebImage. I saw related questions here and in other places but all are in Objective-C syntax and not working for me.

What I did till now:

  1. I downloaded the zip from GitHub
  2. Copied SDWebImage folder to my folder
  3. Tried all possible combinations for import

#import <"SDWebImage/UIImageView+WebCache.h">

import SDWebImage/UIImageView+WebCache.h

etc..

Can someone please help me import it


Solution

  • Firstly, you need configure Bridging Header, it is described here at SO. Use the following:

    #import <SDWebImage/UIImageView+WebCache.h>
    

    This will import Objective-C code to Swift code

    Secondly, just use it, like:

    self.imageView.sd_setImageWithURL(self.imageURL)