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!
Getting the animation view with json file name
let animationView = LOTAnimationView(name: "preloader")
self.view.addSubview(animationView)
animationView.play()
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")
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()
}
}
@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!
Most helpful comment
@muraterd
Try this,
In your XCode project, click on your
preLoader.jsonfile, then in the inspector (Right panel of Xcode ) click on the checkbox with the name of your projet inTarget MemberShip