Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 3.0 Support #1627

Closed
katriciab opened this issue Jul 20, 2016 · 26 comments
Closed

Swift 3.0 Support #1627

katriciab opened this issue Jul 20, 2016 · 26 comments
Milestone

Comments

@katriciab
Copy link

Will there be support for Swift 3.0?

@bpoplauschi
Copy link
Member

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.

@Tinghui
Copy link

Tinghui commented Sep 5, 2016

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

@joristimmerman
Copy link

joristimmerman commented Sep 14, 2016

Any idea when the issue Tinghui mentions gets fixed?
Setting the options as a temp workaround for now.

@gujinku
Copy link

gujinku commented Sep 18, 2016

Won't we need to do any adjustment to Swift3.0?

@gujinku
Copy link

gujinku commented Sep 18, 2016

Can you please take a look? Not sure if you are ware of this. @bpoplauschi

@billionbucks
Copy link

images are not loading anymore after updating to swift 3 ? am i at right place ?

@ghost
Copy link

ghost commented Sep 19, 2016

I confirm, it's not working with Swift 3.0, SDWebImageCompletionBlock not recognized. :(

@joristimmerman
Copy link

joristimmerman commented Sep 20, 2016

@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.

@Toolenaar
Copy link

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

@gujinku
Copy link

gujinku commented Sep 26, 2016

The completion block is called but the image is nil.

@bpoplauschi
Copy link
Member

@billionbucks @ducmaxime @joridor can you provide some image urls that don't work for you so we can test?

@bpoplauschi
Copy link
Member

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

@fmello
Copy link

fmello commented Sep 28, 2016

Hi, is it possible you post this sample project. I am also having the same difficulty. tks

@joristimmerman
Copy link

@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))

@supreetuf
Copy link

supreetuf commented Sep 30, 2016

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.

@bpoplauschi bpoplauschi added this to the 4.0.0 milestone Sep 30, 2016
@henry0475
Copy link

henry0475 commented Oct 6, 2016

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?' ...

@bpoplauschi
Copy link
Member

@henry0475 which version of SDWebImage?

@henry0475
Copy link

henry0475 commented Oct 6, 2016

@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.

@bpoplauschi
Copy link
Member

@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")
                }
        })

@henry0475
Copy link

@bpoplauschi Thanks!! Using your suggestion code, error has been solved. But Xcode showed a new waring, "Expression of type 'SDWebImageDownloadToken?' is unused" . :(

@bpoplauschi
Copy link
Member

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).

@Antilopez
Copy link

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!

@gujinku
Copy link

gujinku commented Oct 8, 2016

@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.

@bpoplauschi
Copy link
Member

@gujinku thanks. About an ETA, in think it will take a few more days to properly test and wrap up the documentation.

@chrisl777
Copy link

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.

@thedp
Copy link

thedp commented Jun 15, 2017

Any update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests