Swift Package Manager install, add your JSON file to Xcode, then LottieAnimationView with a file name. That's the whole setup.
In Xcode: File → Add Package Dependencies. Paste the URL below and add the package.
Drag your JSON file into Xcode (check 'Copy items if needed'), then create a LottieAnimationView with the file name.
import Lottie
class ViewController: UIViewController {
var animationView: LottieAnimationView!
override func viewDidLoad() {
super.viewDidLoad()
animationView = LottieAnimationView(name: "your_animation")
animationView.frame = CGRect(x: 0, y: 0, width: 150, height: 150)
animationView.center = view.center
animationView.loopMode = .loop
animationView.play()
view.addSubview(animationView)
}
}The animationView instance gives you play, pause, stop, and loop mode control.
animationView.play()
animationView.pause()
animationView.stop()
animationView.loopMode = .playOnceDoes Lottie work with SwiftUI?
Yes. Recent versions of lottie-ios ship a native LottieView SwiftUI component. On older versions, wrap LottieAnimationView in UIViewRepresentable.
How do I add the JSON to Xcode?
Drag it into your project navigator with "Copy items if needed" checked. Reference it by name without the extension.
How do I play once and stop?
Set animationView.loopMode = .playOnce before calling play(). It stops on the last frame.
Get your animated icons
Browse icons ready for iOS — free to download.