0

I'm creating a framework where I want to do some animation with SwiftyGif. I have a gif file named "loading.gif" which I want to present. The problem I'm facing is to find the file within the framework.

When my screen loads I initialise the image view for the gif, but it I always get Error : Gif file loading.gif.gif not found in the log and the gif never shows...

override func viewDidLoad() {
    super.viewDidLoad()
    let gif = UIImage(gifName: "loading")
    let imv = UIImageView(gifImage: gif)
    imv.frame = CGRect(origin: .zero, size: containerView.frame.size)
    imv.loopCount = -1
    containerView.addSubview(imv)
    // Do any additional setup after loading the view.
}

Even tried to search a path in the bundle but it always returns nil:

 let path = Bundle(for: type(of: self)).path(forResource: "loading", ofType: "gif")

On my podspec i'm trying to add my .gif files on the resouce

  s.resource = 'DeathStarCore/**/*.{xib,xcassets,gif}'
  s.source_files = 'DeathStarCore/Source/**/*.swift'

What is the proper way to do gifs in a development pod?

Fred Novack
  • 727
  • 9
  • 27
  • "Error : Gif file loading.gif.gif" That's the error, it seems that is has a ".gif" in exceed. I guess that `UIImage(gifName: "loading.gif")` should be `UIImage(gifName: "loading")` (it adds it self the .gif?) – Larme Dec 17 '18 at 13:15
  • Fixed it and still nothing =( – Fred Novack Dec 17 '18 at 23:52

1 Answers1

0

I had the same issue. Adding this in the podspec solved the issue for me.

s.resources = "YourPod/Assets/*.xcassets", "YourPod/**/*.storyboard", "YourPod/**/*.gif"
mshrestha
  • 788
  • 5
  • 14