swiftgif / SwiftGif

[UNMAINTAINED] 🌠 A small UIImage extension with gif support
MIT License
1.33k stars 306 forks source link

Fail to Load GIF in new xcode 10 update with ios 12 #75

Open SubhadipDutta93 opened 6 years ago

SubhadipDutta93 commented 6 years ago

Once i run my app in the debug terminal it shows this - "SwiftGif: Cannot turn image named "battery" into NSDataAsset" how to solve this problem? Thanks in advance.

ArtFeel commented 6 years ago

Don't use XCAsset

imdinesh58 commented 6 years ago

heap buffer overflow ... library crashed

bartoslaw commented 5 years ago

@SubhadipDutta93 and others what I did is:

imageView.image = UIImage.gif(name: gifName)

public class func gif(name: String) -> UIImage? {
        guard let bundleURL = Bundle.main
            .url(forResource: name, withExtension: "gif") else {
                print("SwiftGif: This image named \"\(name)\" does not exist")
                return nil
        }
        guard let imageData = try? Data(contentsOf: bundleURL) else {
            print("SwiftGif: Cannot turn image named \"\(name)\" into NSData")
            return nil
        }

        return gif(data: imageData)
    }

works like a charm

SteveBlackUK commented 4 years ago

+1 for this - didn't work in the Assets folder, worked find elsewhere