Will there be support for Swift 3.0?
Of course it will. Right now, since we don't have any explicit Swift code, I'm not sure if we need to do anything in particular for this.
There is a problem when using SDWebImage with Swift3.
After updating to Swift 3.0, the Swift compiler translates the ObjC headers for UIImageView+WebCache.h into Swift, then it occurs a naming collision.
Please see this stackoverflow question for more details: http://stackoverflow.com/questions/38949214/ambiguous-use-of-sd-setimagewithplaceholderimagecompleted-with-swift-3
Any idea when the issue Tinghui mentions gets fixed?
Setting the options as a temp workaround for now.
Won't we need to do any adjustment to Swift3.0?
Can you please take a look? Not sure if you are ware of this. @bpoplauschi
images are not loading anymore after updating to swift 3 ? am i at right place ?
I confirm, it's not working with Swift 3.0, SDWebImageCompletionBlock not recognized. :(
@billionbucks Had the same for my list with images, the first ones were loaded, after a while it stopped loading pictures.
Set the options to low priority (eg. options: [.continueInBackground, .lowPriority]) and it seemed to be fixed.
Don't think it was caused by Swift 3, maybe it's the iOS 10 SDK, or a combo.
_UPDATE_
Scratch that, still happening for me. It's not occurring on iOS9, but it is on iOS 10.
having the same issues after updating my app to swift 3.0 images stopped loading. Joridor's solution does not work for me. The completion block is fired but when the image that I get back wont seem to load into the UIImageView
The completion block is called but the image is nil.
@billionbucks @ducmaxime @joridor can you provide some image urls that don't work for you so we can test?
PS: I just created a demo Swift 3 project, added SDWebImage and indeed got into the 'ambiguous method' issue, but I easily passed that by adding the options param and then everything worked fine (including downloading and showing the image). I used this url: https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png
Hi, is it possible you post this sample project. I am also having the same difficulty. tks
@bpoplauschi My situation: I have a tableview filled with images. The first +- 50 pictures were working correctly. But if you kept scrolling, the images would stop loading.
In the cells, I call .sd_cancelCurrentImageLoad() in prepareForReuse.
I used sd_setImage(with:placeholderImage:options:completed) to load an image url when setting up the cells.
To make the list work again, I had to specify the option [.continueInBackground, .lowPriority] in the options. (think previous value was: SDWebImageOptions(rawValue:0))
Hi @bpoplauschi I had the same issue, images were not loading in swift 3. I had an existing project in swift 2.3 and converted it to swift 3. After that, this issue started. In my case, it was for few ImageViews the images were not showing, while for others they were showing. After much try and debugging what worked for me was, to remove the ImageView from the storyboard not showing image and add a new ImageView, connect it to view controller and do the code. That fixed it for me.
Recently i used swift 3.0 and also have same problem. Used SDWebImageManager.shared().imageDownloader?.downloadImage,Xcode 8.0 tell me Cannot convert value of type '(UIImage, Data, NSError, Bool) -> ()' to expected argument type 'SDWebImageDownloaderCompletedBlock?' ...
@henry0475 which version of SDWebImage?
@bpoplauschi Hi, I'm using 4.0.0 version. I don't know how to resolve this problem.My code:
SDWebImageManager.shared().imageDownloader?.downloadImage(with: photoURL, options: SDWebImageDownloaderOptions.allowInvalidSSLCertificates, progress: { (min: Int, max: Int, nil) in
print("loading……")
}, completed: { (image: UIImage, data: Data, error: NSError, finished: Bool) in
if image != nil {
print("finished")
} else {
print("wrong")
}
})
Then Xcode has error,likes above.
@henrik for version 4.0.0, use
SDWebImageManager.shared().imageDownloader?.downloadImage(with: url, options: SDWebImageDownloaderOptions.allowInvalidSSLCertificates, progress: { (min, max, url) in
print("loading……")
}, completed: { (image, data, error, finished) in
if image != nil {
print("finished")
} else {
print("wrong")
}
})
@bpoplauschi Thanks!! Using your suggestion code, error has been solved. But Xcode showed a new waring, "Expression of type 'SDWebImageDownloadToken?' is unused" . :(
Here's my sample project: https://github.com/rs/SDWebImage/files/515471/Swift3TestSDWebImage.zip.
If your images are available via http, you need to add the App Transport Security Settings/Allow Arbitrary Loads=YES into your Info.plist to allow this unsecure connections.
Also, you can try the 4.0.0 (right now, beta2 is available via cocoapods, even though it's not an official release yet).
Hi!
I'm using your library on version 4.0.0 beta 2 (its great btw). And i was experiencing issues with swift 3.0 as well.
Tried all your options and while in most cases the problem was solved, the case where the profile picture had a circular corner radius kept showing an empty image.
I tackled the problem by removing the ciruclar radius layer and the library was working again. Maybe it helps you find the problem (or maybe its just my case i dont know).
This was my problematic code:
self.profileImageView.layer.cornerRadius = self.profileImageView.frame.size.width / 2;
I solved the problem by removing that line and adding another image on top with static png croped circular (horrible, i know, but deadlines are my priority right now).
Hope it helps someone!
@bpoplauschi
Awesome work!
I got the 4.0.0 beta2 and we love it! We cannot wait to integrate it into our production app in next release. So we would be grateful if you can provide the rough release ETA of SDWebImage 4.0.0.
@gujinku thanks. About an ETA, in think it will take a few more days to properly test and wrap up the documentation.
I had issues with the compiler finding "sd_setImage" until I added an "import WebImage" at the top of my file. Just an FYI if some people are having some build errors in their Swift 3 project.
Any update on this issue?
Most helpful comment
There is a problem when using SDWebImage with Swift3.
After updating to Swift 3.0, the Swift compiler translates the ObjC headers for UIImageView+WebCache.h into Swift, then it occurs a naming collision.
Please see this stackoverflow question for more details: http://stackoverflow.com/questions/38949214/ambiguous-use-of-sd-setimagewithplaceholderimagecompleted-with-swift-3