Lottie

4.3.1

An iOS library to natively render After Effects vector animations
airbnb/lottie-ios

What's New

4.3.1

2023-09-20T21:38:44Z

Lottie 4.3.0 adds many new features, including:

  • Official support for SwiftUI!
  • A public Core Animation CALayer subclass
  • Support for reduced motion
  • Support for drop shadow layer effects
  • Support for visionOS

You can learn more about Lottie 4.3.0 in this announcement: Lottie 4.3.0 now available, with official support for SwiftUI #2189

Lottie 4.3.1 fixes a small regression introduced by 4.3.0: #2193

New Features

  • Add SwiftUI LottieView, which wraps UIKit LottieAnimationView
  • Add SwiftUI LottieSwitch, which wraps UIKit AnimatedSwitch (#2138)
  • Add SwiftUI LottieButton, which wraps AnimatedButton (#2139)
  • AnimatedSwitch and AnimatedButton now support macOS (#2138, #2139)
  • Add LottieAnimationLayer, a Core Animation CALayer subclass for playing Lottie animations (#2073)
  • Add support for rendering drop shadow layer effects (#2142)
  • Add API for playing multiple markers sequentially (#2084)
  • Play "reduced motion" marker if UIAccessibility.isReduceMotionEnabled is true (#2110)
  • Update text provider API to use full AnimationKeypath values (#2183)
  • Add support for visionOS (#2152)
  • Drop support for Swift 5.5 (#2152)
  • Add contents gravity configuration to AnimationImageProvider (#2177)
  • Add support for customizing stroke width values using FloatValueProvider (#2179)
  • Adopt Sendable to support using Lottie with strict concurrency enabled (#2126)
  • Add LottiePlaybackMode to support declarative playback configuration (#2128)
  • Add option make main thread rendering engine force display update on every frame (#2168)
  • Add a option to prevent caching images from AnimationImageProvider (#2171)
  • Add support for customizing gradient values using GradientValueProvider (#2182)
  • Added additional support for multiple animations in DotLottieFile (#2074)
  • Add helper method to initialize DotLottieFile with data (#2090)

Bug fixes

  • Remove .../ZipFoundation/README.md from targets and *.md* files from podspec (#2057)*
  • Fix issue where layers with negative X scale values could be pixelated (#2067)
  • Fix warnings when building with Swift 5.9 (#2072)
  • Restructure ValueProviderStore to not accumulate multiple values for the same key (#2082)
  • Disable bitcode when building XCFramework (#2121)
  • Fix unhandled file warning when building with SPM (https://github.com/airbnb/lottie-ios/pull/213)
  • Fix support for customizing color of SolidLayer using ColorValueProvider (#2154)
  • Fix issue where shape items could be unexpectedly ignored (#2156)
  • Fix issue where skew keyframes would unexpectedly not animate (#2157)
  • Fix issue where value providers could be ignored when falling back to main thread rendering engine (#2164)

Thanks to everyone who contributed to this release!

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.3.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.

Data collection

The Lottie SDK does not collect any data. We provide this notice to help you fill out App Privacy Details.

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:

  • the Lottie framework (for iOS, macOS, and tvOS)
  • unit tests and snapshot tests (for iOS, must be run on an iPhone 8 simulator)
  • an Example iOS app that lets you browse and test over 100 sample animations included in the repo

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

  • To add a new sample animation to the snapshot testing suite, you can add the .json file to Tests/Samples. Re-run the snapshot tests to generate the new snapshot image files.
  • To update existing snapshots after making changes, you can set isRecording = true in SnapshotTests.swift setUp() method and then re-run the snapshot tests.

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

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Oct 02 2023 08:36:11 GMT-0900 (Hawaii-Aleutian Daylight Time)