Skip to content

Commit

Permalink
Fix macOS build issues for apps using lottie-spm XCFramework (#1960)
Browse files Browse the repository at this point in the history
  • Loading branch information
calda authored Feb 15, 2023
1 parent 0e5d3c0 commit 4e51b71
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ To install Lottie using [Swift Package Manager](https://github.com/apple/swift-p
or you can add the following dependency to your `Package.swift`:

```swift
.package(url: "https://github.com/airbnb/lottie-spm.git", from: "4.1.2")
.package(url: "https://github.com/airbnb/lottie-spm.git", from: "4.1.3")
```

When using Swift Package Manager we recommend using the [lottie-spm](https://github.com/airbnb/lottie-spm) repo instead of the main lottie-ios repo. The main git repository for [lottie-ios](https://github.com/airbnb/lottie-ios) is somewhat large (300+ MB), and Swift Package Manager always downloads the full repository with all git history. The [lottie-spm](https://github.com/airbnb/lottie-spm) repo is much smaller (less than 500kb), so can be downloaded much more quickly.
Expand Down
6 changes: 5 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace :build do
sh 'rm -rf .build/archives'
xcodebuild('archive -workspace Lottie.xcworkspace -scheme "Lottie (iOS)" -destination generic/platform=iOS -archivePath ".build/archives/Lottie_iOS" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES')
xcodebuild('archive -workspace Lottie.xcworkspace -scheme "Lottie (iOS)" -destination "generic/platform=iOS Simulator" -archivePath ".build/archives/Lottie_iOS_Simulator" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES')
xcodebuild('archive -workspace Lottie.xcworkspace -scheme "Lottie (iOS)" -destination "generic/platform=macOS,variant=Mac Catalyst" -archivePath ".build/archives/Lottie_Mac_Catalyst" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES')
xcodebuild('archive -workspace Lottie.xcworkspace -scheme "Lottie (macOS)" -destination generic/platform=macOS -archivePath ".build/archives/Lottie_macOS" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES')
xcodebuild('archive -workspace Lottie.xcworkspace -scheme "Lottie (tvOS)" -destination generic/platform=tvOS -archivePath ".build/archives/Lottie_tvOS" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES')
xcodebuild('archive -workspace Lottie.xcworkspace -scheme "Lottie (tvOS)" -destination "generic/platform=tvOS Simulator" -archivePath ".build/archives/Lottie_tvOS_Simulator" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES')
Expand All @@ -57,13 +58,16 @@ namespace :build do
'-create-xcframework',
'-framework .build/archives/Lottie_iOS.xcarchive/Products/Library/Frameworks/Lottie.framework',
'-framework .build/archives/Lottie_iOS_Simulator.xcarchive/Products/Library/Frameworks/Lottie.framework',
'-framework .build/archives/Lottie_Mac_Catalyst.xcarchive/Products/Library/Frameworks/Lottie.framework',
'-framework .build/archives/Lottie_macOS.xcarchive/Products/Library/Frameworks/Lottie.framework',
'-framework .build/archives/Lottie_tvOS.xcarchive/Products/Library/Frameworks/Lottie.framework',
'-framework .build/archives/Lottie_tvOS_Simulator.xcarchive/Products/Library/Frameworks/Lottie.framework',
'-output .build/archives/Lottie.xcframework'
].join(" "))
Dir.chdir('.build/archives') do
sh 'zip -r Lottie.xcframework.zip Lottie.xcframework'
# Use --symlinks to avoid "Multiple binaries share the same codesign path. This can happen if your build process copies frameworks by following symlinks."
# error when validating macOS apps (#1948)
sh 'zip -r --symlinks Lottie.xcframework.zip Lottie.xcframework'
sh 'rm -rf Lottie.xcframework'
end
sh 'swift package compute-checksum .build/archives/Lottie.xcframework.zip'
Expand Down
14 changes: 7 additions & 7 deletions Tests/PerformanceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class PerformanceTests: XCTestCase {
// This is basically a snapshot test for the performance of the Core Animation engine
// compared to the Main Thread engine. Currently, the Core Animation engine is
// about the same speed as the Main Thread engine in this example.
XCTAssertEqual(ratio, 1.0, accuracy: 0.45)
XCTAssertEqual(ratio, 1.0, accuracy: 1.0)
}

func testAnimationViewSetup_complexAnimation() {
Expand All @@ -36,7 +36,7 @@ final class PerformanceTests: XCTestCase {

// The Core Animation engine is currently about 1.7x slower than the
// Main Thread engine in this example.
XCTAssertEqual(ratio, 1.7, accuracy: 0.7)
XCTAssertEqual(ratio, 1.7, accuracy: 1.0)
}

func testAnimationViewSetup_automaticEngine() {
Expand All @@ -50,29 +50,29 @@ final class PerformanceTests: XCTestCase {

// The automatic engine option should have the same performance as the core animation engine,
// when rendering an animation supported by the CA engine.
XCTAssertEqual(ratio, 1.0, accuracy: 0.5)
XCTAssertEqual(ratio, 1.0, accuracy: 1.0)
}

func testAnimationViewScrubbing_simpleAnimation() {
let ratio = compareEngineScrubbingPerformance(for: simpleAnimation, iterations: 2000)
XCTAssertEqual(ratio, 0.01, accuracy: 0.05)
XCTAssertEqual(ratio, 0.01, accuracy: 0.1)
}

func testAnimationViewScrubbing_complexAnimation() {
let ratio = compareEngineScrubbingPerformance(for: complexAnimation, iterations: 2000)
XCTAssertEqual(ratio, 0.01, accuracy: 0.05)
XCTAssertEqual(ratio, 0.01, accuracy: 0.1)
}

func testParsing_simpleAnimation() throws {
let data = try XCTUnwrap(Bundle.module.getAnimationData("loading_dots_1", subdirectory: "Samples/LottieFiles"))
let ratio = try compareDeserializationPerformance(data: data, iterations: 2000)
XCTAssertEqual(ratio, 2, accuracy: 0.65)
XCTAssertEqual(ratio, 2, accuracy: 1.0)
}

func testParsing_complexAnimation() throws {
let data = try XCTUnwrap(Bundle.module.getAnimationData("LottieLogo2", subdirectory: "Samples"))
let ratio = try compareDeserializationPerformance(data: data, iterations: 500)
XCTAssertEqual(ratio, 1.7, accuracy: 0.6)
XCTAssertEqual(ratio, 1.7, accuracy: 1.0)
}

override func setUp() {
Expand Down
2 changes: 1 addition & 1 deletion lottie-ios.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'lottie-ios'
s.version = '4.1.2'
s.version = '4.1.3'
s.summary = 'A library to render native animations from bodymovin json'

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lottie-ios",
"version": "4.1.2",
"version": "4.1.3",
"description": "Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with bodymovin and renders the vector animations natively on mobile and through React Native!",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 4e51b71

Please sign in to comment.