Sdwebimage: How to use this SDK with Swift?

Created on 22 Dec 2014  路  11Comments  路  Source: SDWebImage/SDWebImage

Hi,
I am working on Swift based project and I have to download and upload images in that app. I have already used your SDK with Objective C and it worked great! But now I want to use your SDK with Swift language but you haben't mentioned the steps on how to use this SDK with Swift. Please help me in that regard as I have mentioned my query on Stackoverflow but I didn't get any help from there!

Most helpful comment

Here's how I got it working (using CocoaPods and dynamic frameworks, no messy bridging headers):

Podfile:

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
  pod 'SDWebImage'
end

Run pod install. Then, at the top of your source file add:

import SDWebImage

Now it's ready to use!

cell.imageView.sd_setImageWithURL(myUrl)

All 11 comments

Any update please!

I havent done it but you should just be able to #import <SDWebImage/SDWebImage.h> in your bridging header that is generated if you have a mixed swift/objc-c project. if it's a pure swift project you need to add that header yourself (which i don't know how to do myself, but you can force xcode to do it for you if you add an obj-c file and throw that file away afterwards).

Cocoapods support Swift.

Import via Cocoapods.

import SDWebImage in your swift sheet.

look for sd_* methods on UIImageView!

How to resolve this issue?

We need to add a Swift section in our Readme.md file, explaining how to get SDWebImage working with Swift.

a list with all available functions would be nice, too.

The problem is that extensions don't work with Swift frameworks yet. Several CocoaPods are suffering from this :(((

http://stackoverflow.com/questions/24175596/swift-framework-does-not-include-symbols-from-extensions-to-generic-structs

Please make some noise in the Apple forums and feedback.

Here's how I got it working (using CocoaPods and dynamic frameworks, no messy bridging headers):

Podfile:

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
  pod 'SDWebImage'
end

Run pod install. Then, at the top of your source file add:

import SDWebImage

Now it's ready to use!

cell.imageView.sd_setImageWithURL(myUrl)

closing this based on comments above. thanks @adrianmacneil

Hi @amacneil ,

i have installed the pod file, but there is no "SDWebImage" file , when i am trying to import "import SDWebImage" i am getting error

screen shot 2016-07-20 at 9 45 16 pm

Was this page helpful?
0 / 5 - 0 ratings