Lottie-ios: Animation Not Found

Created on 23 Sep 2017  路  5Comments  路  Source: airbnb/lottie-ios

Lottie-ios Issue

Hello! Sorry you are having an Issue! Please help us make Lottie better by filling everything below out with as much information as you can so we can try to reproduce and fix the issue!

Check these before submitting:

  • [x] Updated to the latest (2.1.3) version of Lottie
  • [x] The issue doesnt involve and Unsupported Feature
  • [x] This issue isnt related to another open issue

This issue is a

  • [x] Non-Crashing (Visual or otherwise) Bug

What Platform are you on?

  • [x] iOS (11)

Expected Behavior

Getting the animation view with json file name

let animationView = LOTAnimationView(name: "preloader")
self.view.addSubview(animationView)
animationView.play()

Actual Behavior

When i'm trying to get animation like this
var loadingView = LOTAnimationView(name: "preloader")
I'm taking this error: +[LOTComposition animationNamed:inBundle:]: Animation Not Found

But getting the animation like below works fine
var loadingView = LOTAnimationView(filePath: "/Users/muraterdogan/Git/iOS/Swift/LottieTest/LottieTest/preloader.json")

Code Example

import UIKit
import Lottie

class ViewController: UIViewController {
    var loadingView = LOTAnimationView(name: "preloader")

    override func viewDidLoad() {
        super.viewDidLoad()

        loadingView.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
        loadingView.loopAnimation = true
        loadingView.contentMode = .scaleAspectFill
        loadingView.center = view.center
        view.addSubview(loadingView)
    }

    @IBAction func start(_ sender: Any) {
        loadingView.play()
    }
}

Animation JSON

preloader.json.zip

Most helpful comment

@muraterd
Try this,
In your XCode project, click on your preLoader.json file, then in the inspector (Right panel of Xcode ) click on the checkbox with the name of your projet in Target MemberShip

All 5 comments

@muraterd I have the same problem.

@muraterd
Try this,
In your XCode project, click on your preLoader.json file, then in the inspector (Right panel of Xcode ) click on the checkbox with the name of your projet in Target MemberShip

@Wathis
Thank you that solved my issue. I'm new to ios development and sorry for that silly question :) I learned a new thing from you :)

I also had this issue, but I had a problem with the name of my file - the file name can not contain dots, because of the following:

LOTComposition:
+ (nullable instancetype)animationNamed:(nonnull NSString *)animationName inBundle:(nonnull NSBundle *)bundle {
  NSArray *components = [animationName componentsSeparatedByString:@"."];
  animationName = components.firstObject;

@Wathis Thanks bud that worked!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajeshbeats picture rajeshbeats  路  3Comments

JALsnipe picture JALsnipe  路  4Comments

loganblevins picture loganblevins  路  3Comments

amannayak0007 picture amannayak0007  路  3Comments

petoye picture petoye  路  3Comments