Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
Crash with error Thread 1: EXC_BAD_INSTRUCTION (code=1, subcode=0x210007) in ImageDownloader.swift line 169.
When adding any URL via URL(string:) and then setting in an UIImageview the image with UIImageView.kf.setImage(with:url)a crash occurs in line169 in ImageDownloader.swift:
sessionDelegate.onReceiveSessionChallenge.delegate(on: self) { (self, invoke) in
self.authenticationChallengeResponder?.downloader(self, didReceive: invoke.1, completionHandler: invoke.2)
}
Clone and run the sample project at:https://github.com/juanjoseluisgarcia/kignfishertest.git
It happens with all branches and version 5.9.0. I am downloading KingFIsher via Package Manager in Xcode 11.2
Seeing exactly the same issue here. Project was running fine, updated to Xcode 11.2 Beta 2 and now I get this crash.
Can confirm happened to me on Xcode 11.2 Beta 2 just now, works fine in 11.1 (I'm Using Kingfisher for the first time.)
Crashes on the exact same line, but different error code than OP
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
Had created an instance of KFImage with a URL.
Same Issue. Kingfisher version 5.9.0
Thanks for reporting it. It seems that there are some critical regressions in Swift 5.1.1 linker which causes a few problems. Such as https://bugs.swift.org/browse/SR-11564 and https://bugs.swift.org/browse/SR-11604
I am now not sure whether is this issue also related to Swift linker or not. I am waiting for a direct download link for Xcode 11.2 xip file (since the App Store installing is broken for me). But now it is not available yet on Apple's release page. When I can get the release version of 11.2 installed, I will start to find a way to work around for it.
Before that, I strongly suggest keeping Xcode 11.1 for a while.
@juanjoseluisgarcia @MattCheetham @tarasis @chrisjeane
May I confirm that you are all using Swift Package Manager to add Kingfisher to your project? According to some attempts myself, it seems that this issue only happens when using SPM. Is this also your case? It would be a great help if you can let me know your integrating way!
It seems duplicated to #1306 and https://github.com/mxcl/PromiseKit/issues/1099
This issue is already reported in https://bugs.swift.org/browse/SR-11604, https://bugs.swift.org/browse/SR-11564, and https://bugs.swift.org/browse/SR-11567
Currently, I cannot find a way to solve it except waiting for Apple to give a fix on SPM.
If SPM is not a must for your project, you can switch to CocoaPods or Carthage to get a workaround. Otherwise, I suggest keeping Xcode 11.1 for a while longer. :(
I can confirm that switching to Carthage for Kingfisher, and Kingfisher alone, that is, leaving all the rest of my particular set of dependencies in Swift Package Manager works perfectly. I keep the issue open just for others to see the fix. Please Refers to stackoverflow question https://stackoverflow.com/questions/58629726/kingfisher-5-0-crashing-with-exc-bad-instruction-in-xcode-12-1/58658048#58658048
Per a tweet on twitter, the workaround for this issue with Xcode 11.2 is to use the build setting DEAD_CODE_STRIPPING = NO
I can confirm that @tarasis has given the fix for the Swift Package Manager. It works like a charm.
This issue did not get a fix in the latest Xcode 11.2.1 GM today. It seems that there is a "workaround" to try to rearrange method order to prevent the stripping happen. But there are quite a few cases in Kingfisher this would happen and it is hard to test them all. So I suggest the workaround posted by @tarasis to turn off DEAD_CODE_STRIPPING before Apple can give a fix on it.
This bug is fixed in the latest Xcode 11.3 beta
It's good news! So I am closing this issue now.
Xcode 11.3 was released and this issue has been fixed. If you still have crashing on it, please try to upgrade to the latest Xcode, and do a full clean including the derived data.
Seems that the installation guide section should be updated, since this is resolved, right?
Yes. Edited.
Most helpful comment
Per a tweet on twitter, the workaround for this issue with Xcode 11.2 is to use the build setting DEAD_CODE_STRIPPING = NO
https://twitter.com/tcldr1/status/1190396639334285312?s=21