lottie-ios README

The project's README from github.com/airbnb/lottie-ios. As one markdown file: README.md.

Lottie for iOS

Version Carthage Compatible SwiftPM License Platform Swift Versions

View documentation, FAQ, help, examples, and more at airbnb.io/lottie

Lottie is a cross-platform library for iOS, macOS, tvOS, visionOS, Android, and Web that natively renders vector-based animations and art in realtime with minimal code.

Lottie loads and renders animations and vectors exported in the bodymovin JSON format. Bodymovin JSON can be created and exported from After Effects with bodymovin, Sketch with Lottie Sketch Export, and from Haiku.

Designers can create and ship beautiful animations without an engineer painstakingly recreating them by hand. Since the animations are backed by JSON, they are extremely small in size but can be large in complexity! Animations can be played, resized, looped, sped up, slowed down, reversed, and even interactively scrubbed. Lottie can play or loop just a portion of the animation as well, the possibilities are endless! Animations can even be changed at runtime in various ways! Change the color, position, or any keyframable value!

Here is just a small sampling of the power of Lottie

Example1 Example2

Example3

Abcs

Installing Lottie

Lottie supports Swift Package Manager, CocoaPods, and Carthage (Both dynamic and static).

Github Repo

You can pull the Lottie Github Repo and include the Lottie.xcodeproj to build a dynamic or static library.

Swift Package Manager

To install Lottie using Swift Package Manager you can follow the tutorial published by Apple using the URL for the Lottie repo with the current version:

  1. In Xcode, select “File” → “Add Packages...”
  2. Enter https://github.com/airbnb/lottie-spm.git

or you can add the following dependency to your Package.swift:

.package(url: "https://github.com/airbnb/lottie-spm.git", from: "4.6.1")

When using Swift Package Manager we recommend using the lottie-spm repo instead of the main lottie-ios repo. The main git repository for lottie-ios is somewhat large (300+ MB), and Swift Package Manager always downloads the full repository with all git history. The lottie-spm repo is much smaller (less than 500kb), so can be downloaded much more quickly.

Instead of downloading the full git history of Lottie and building it from source, the lottie-spm repo just contains a pointer to the precompiled XCFramework included in the latest lottie-ios release (typically ~8MB). If you prefer to include Lottie source directly your project, you can directly depend on the main lottie-ios repo by referencing https://github.com/airbnb/lottie-ios.git instead.

CocoaPods

Add the pod to your Podfile:

pod 'lottie-ios'

And then run:

pod install

After installing the cocoapod into your project import Lottie with

import Lottie

Carthage

Add Lottie to your Cartfile:

github "airbnb/lottie-ios" "master"

And then run:

carthage update

In your application targets “General” tab under the “Linked Frameworks and Libraries” section, drag and drop lottie-ios.framework from the Carthage/Build/iOS directory that carthage update produced.

Swift Version Support

Lottie supports Swift / Xcode versions back to the minimum version that is permitted by Apple for submissions to the App Store. You can see the most up-to-date information for which Swift versions Lottie supports on Swift Package Index:

Swift Versions

Privacy

Lottie does not collect any data. We provide this notice to help you fill out App Privacy Details. We additionally provide a privacy manifest which can be included in your app.

Security

We distribute XCFramework bundles for each release on GitHub. In Lottie 4.4.0 and later, these XCFramework bundles include a code signature. These bundles are self-signed under the name "Lottie iOS" and have the following fingerprint:

89 2F 1B 43 04 7B 50 53 8F 2F 46 EA D9 29 00 DD 3D 48 11 F358 21 78 C0 61 A5 FB 20 F1 11 CB 26

In Xcode you can verify this by selecting Lottie.xcframework and confirming that it shows the following information:

Code Signature in Xcode

Contributing

We always appreciate contributions from the community. To make changes to the project, you can clone the repo and open Lottie.xcworkspace. This workspace includes:

All pull requests with new features or bug fixes that affect how animations render should include snapshot test cases that validate the included changes.

The project also includes several helpful commands defined in our Rakefile. To use these, you need to install Bundler:

$ sudo gem install bundle
$ bundle install

For example, all Swift code should be formatted according to the Airbnb Swift Style Guide. After making changes, you can reformat the code automatically using SwiftFormat and SwiftLint by running bundle exec rake format:swift. Other helpful commands include:

$ bundle exec rake build:all # builds all targets for all platforms
$ bundle exec rake build:package:iOS # builds the Lottie package for iOS
$ bundle exec rake test:package # tests the Lottie package
$ bundle exec rake format:swift # reformat Swift code based on the Airbnb Swift Style Guide

lottie-ios (airbnb/lottie-ios)

swift-package-manager
Searching Database…

What is this?Lottie for iOS is a Swift library that natively renders vector-based animations and art in realtime with minimal code. Animations come as bodymovin JSON files, typically exported from After Effects.
Is this an app I install, or a library I add to my Xcode project?It is a library you add as a dependency to your Xcode project; your app code then loads and displays bodymovin JSON animation files. There is no standalone app here.
How do I add it to my project?Three supported ways: Swift Package Manager (File → Add Packages... in Xcode), CocoaPods (add the pod to your Podfile and run pod install), or Carthage. For SPM, prefer the lottie-spm repo, then import Lottie in your code.
Where do the animations themselves come from — do I need After Effects?You do not hand-code the animations: designers export bodymovin JSON from After Effects (via the bodymovin plugin), from Sketch with Lottie Sketch Export, or from Haiku, and Lottie just renders that JSON.
Any gotchas when installing with Swift Package Manager?Yes: the main lottie-ios repo is large (300+ MB) and SPM always downloads the full git history. Use the lottie-spm repo instead — it is under 500 KB and points to a precompiled ~8 MB XCFramework.
Does this package work beyond iPhone — say macOS or tvOS?This repo builds the Apple-side framework: iOS, macOS, tvOS, and visionOS. The broader Lottie family also covers Android and Web through separate libraries.
Does the library collect any data my app must disclose?No — Lottie does not collect any data, and the project ships a privacy manifest you can include in your app to help fill out Apple's App Privacy details.
What can I do with an animation once it's loaded in my app?Plenty: play, resize, loop, speed up, slow down, reverse, or interactively scrub it, and you can play or loop just a portion. At runtime you can also change the color, position, or any keyframable value.
Why would a team pick Lottie over hand-coded animations?Designers create and ship animations straight from After Effects without an engineer painstakingly recreating them by hand. And because animations are backed by JSON, the files stay extremely small while the animation itself can be quite complex.
How can I verify the precompiled framework I download is legit?Since Lottie 4.4.0 the release XCFramework bundles carry a code signature, self-signed under the name 'Lottie iOS' with a published fingerprint. Xcode shows this information when you select Lottie.xcframework.
Creator
airbnb
Size
198.1 MB
Stars
26.9K
Age
10y
Commits · 90 Days