Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

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

Open
SubhadipDutta93 opened this issue Sep 22, 2018 · 4 comments
Open

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

SubhadipDutta93 opened this issue Sep 22, 2018 · 4 comments

Comments

@SubhadipDutta93
Copy link

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
Copy link

ArtFeel commented Oct 1, 2018

Don't use XCAsset

@imdinesh58
Copy link

imdinesh58 commented Nov 17, 2018

heap buffer overflow ... library crashed

@bartoslaw
Copy link

bartoslaw commented Dec 20, 2018

@SubhadipDutta93 and others what I did is:

  • create a new group called Gifs (you can name it whatever you want)
  • put your files in there

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants