Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI to build for visionOS #2287

Merged
merged 15 commits into from Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
90 changes: 54 additions & 36 deletions .github/workflows/main.yml
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ master ]

jobs:
build-package-macos-13:
build-package-no-visionOS:
name: "Build Package"
runs-on: macos-13
strategy:
Expand All @@ -16,29 +16,42 @@ jobs:
xcode:
- '14.1' # Swift 5.7
- '14.3' # Swift 5.8
- '15.0' # Swift 5.9
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup
with:
xcode: ${{ matrix.xcode }}
- name: Build Package
# Once there is a production Xcode version with the visionOS SDK,
# we will want to use that version without `SKIP_VISION_OS=true`
# Only Xcode 15.2 and later support visionOS, so exclude it on earlier versions.
run: SKIP_VISION_OS=true bundle exec rake build:package:all

build-package:
name: "Build Package"
runs-on: macos-13
strategy:
fail-fast: false
matrix:
xcode:
- '15.2' # Swift 5.9
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup
with:
xcode: ${{ matrix.xcode }}
- name: Build Package
run: bundle exec rake build:package:all


build-example:
name: "Build Example App"
runs-on: macos-13
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup
with:
xcode: '15.0' # Swift 5.9
xcode: '15.2' # Swift 5.9
- name: Build Example
# Once there is a production Xcode version with the visionOS SDK,
# we will want to remove `SKIP_VISION_OS=true`
run: SKIP_VISION_OS=true bundle exec rake build:example:all
run: bundle exec rake build:example:all

test-package:
name: "Test Package"
Expand All @@ -47,7 +60,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup
with:
xcode: '15.0' # Swift 5.9
xcode: '15.2' # Swift 5.9
- name: Test Package
run: bundle exec rake test:package
- name: Process test artifacts
Expand All @@ -72,7 +85,7 @@ jobs:
EMERGE_API_TOKEN: ${{ secrets.EMERGE_API_TOKEN }}
PR_NUMBER: ${{ github.event.number }}

build-xcframework-macos-13:
build-xcframework-minimum-supported-version:
name: "Build XCFramework"
runs-on: macos-13
strategy:
Expand All @@ -83,6 +96,10 @@ jobs:
# will be able to use these XCFrameworks and the lottie-spm package.
# This should be the minimum Xcode version permitted by the App Store.
# As of April 2023, this is Xcode 14.1: https://developer.apple.com/news/?id=jd9wcyov
# - TODO: Once this minimum supported Xcode version is 15.0 or later,
# we can use Xcode 15.2 here and remove the `build-xcframework-with-visionOS-support` job.
# Testing in https://github.com/airbnb/lottie-spm/pull/12 shows that Xcode 15.0 can
# use an XCFramework built by Xcode 15.2.
- '14.1' # Swift 5.7.1
steps:
- uses: actions/checkout@v2
Expand All @@ -95,19 +112,36 @@ jobs:
with:
xcode: ${{ matrix.xcode }}
- name: Build XCFramework
# Once there is a production Xcode version with the visionOS SDK, we will
# need to also build an XCFramework using that version but without `SKIP_VISION_OS=true`
run: SKIP_VISION_OS=true bundle exec rake build:xcframework[Lottie-Xcode-${{ matrix.xcode }}]
- name: Upload XCFramework
uses: actions/upload-artifact@v2
with:
name: BuildProducts
# The xcframework is at the path `.build/archives/Lottie.xcframework.zip`.
# GitHub always zips the artifacts before uploading, so if we uploaded the .xframework.zip
# directly then it would actually upload a double-zip (a .zip containing our `Lottie.xcframework.zip`).
# This is confusing especially since macOS Archive Utility automatially unzips both layers at once.
# Instead, we upload the entire archives folder, resulting in an `XCFramework.zip` that unzips
# to an `archives` directory containing our `Lottie.xcframework.zip`.
path: .build/archives

build-xcframework-with-visionOS-support:
name: "Build XCFramework"
runs-on: macos-13
strategy:
matrix:
xcode:
- '15.2' # Swift 5.9, first Xcode version with visionOS support.
steps:
- uses: actions/checkout@v2
- uses: apple-actions/import-codesign-certs@v2
continue-on-error: true
with:
p12-file-base64: ${{ secrets.SIGNING_CERTIFICATE_BASE_64 }}
p12-password: ${{ secrets.SIGNING_CERTIFICATE_PASSWORD }}
- uses: ./.github/actions/setup
with:
xcode: ${{ matrix.xcode }}
- name: Build XCFramework
run: bundle exec rake build:xcframework[Lottie-Xcode-${{ matrix.xcode }}]
- name: Upload XCFramework
uses: actions/upload-artifact@v2
with:
name: BuildProducts
path: .build/archives

cocoapod:
Expand All @@ -127,7 +161,7 @@ jobs:
strategy:
matrix:
xcode:
- '15.0' # Swift 5.9
- '15.2' # Swift 5.9
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup
Expand All @@ -137,22 +171,6 @@ jobs:
- name: Test Swift Package Manager support
run: bundle exec rake test:spm

spm-xcode-14:
name: "Test Swift Package Manager"
runs-on: macos-13
strategy:
matrix:
xcode:
- '15.0' # Swift 5.9
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup
with:
install-mint: true
xcode: ${{ matrix.xcode }}
- name: Test Swift Package Manager support
run: SKIP_VISION_OS=true bundle exec rake test:spm

carthage:
name: "Test Carthage support"
runs-on: macos-13
Expand All @@ -162,7 +180,7 @@ jobs:
with:
install-mint: true
install-carthage: true
xcode: '15.0' # Swift 5.9
xcode: '15.2' # Swift 5.9
- name: Test Carthage support
run: bundle exec rake test:carthage

Expand Down
29 changes: 19 additions & 10 deletions Rakefile
Expand Up @@ -146,17 +146,21 @@ namespace :test do
sh 'cp -R [^script]* script/test-carthage/Carthage/Checkouts/lottie-ios'

Dir.chdir('script/test-carthage') do
# Build the LottieCarthage framework scheme
installVisionOSIfNecessary()

# Build the Lottie framework scheme
sh 'carthage build --use-xcframeworks'

# Delete Carthage's derived data to verify that the built .xcframework doesn't depend on any
# side effects from building on this specific machine.
# https://github.com/airbnb/lottie-ios/issues/1492
sh 'rm -rf ~/Library/Caches/org.carthage.CarthageKit/DerivedData'

# Build a test app that imports and uses the LottieCarthage framework
xcodebuild('build -scheme CarthageTest -destination "platform=iOS Simulator,name=iPhone SE (3rd generation)"')
xcodebuild('build -scheme CarthageTest-macOS')
# Build a test app that imports and uses the Lottie framework built via Carthage
xcodebuild('build -scheme CarthageTest -destination "platform=iOS Simulator,name=iPhone SE (3rd generation)"')
xcodebuild('build -scheme CarthageTest -destination generic/platform=macOS')
xcodebuild('build -scheme CarthageTest -destination "platform=tvOS Simulator,name=Apple TV"')
xcodebuild('build -scheme CarthageTest -destination "platform=visionOS Simulator,name=Apple Vision Pro"')
end
end

Expand Down Expand Up @@ -247,16 +251,21 @@ def xcodebuild(command)
end

# Runs the given code block, unless `SKIP_VISION_OS=true`.
# This can be removed once CI only uses Xcode 15+.
# TODO: Remove this once CI only uses Xcode 15.2+.
def ifVisionOSEnabled
if ENV["SKIP_VISION_OS"] == "true"
puts "Skipping visionOS build"
else
# As of 9/5/23 the GitHub Actions runner doesn't include the visionOS SDK by default,
# so we have to download it manually. Following the suggested workaround from
# https://github.com/actions/runner-images/issues/8144#issuecomment-1702786388
`brew install xcodesorg/made/xcodes`
`xcodes runtimes install 'visionOS 1.0-beta3'`
installVisionOSIfNecessary()
yield
end
end

def installVisionOSIfNecessary
# visionOS is unsupported by default on Intel, but we can override this
# https://github.com/actions/runner-images/issues/8144#issuecomment-1902072070
sh 'defaults write com.apple.dt.Xcode AllowUnsupportedVisionOSHost -bool YES'
sh 'defaults write com.apple.CoreSimulator AllowUnsupportedVisionOSHost -bool YES'

xcodebuild("-downloadPlatform visionOS")
end
2 changes: 1 addition & 1 deletion Sources/Private/EmbeddedLibraries/LRUCache/LRUCache.swift
Expand Up @@ -33,7 +33,7 @@

import Foundation

#if os(iOS) || os(tvOS)
#if canImport(UIKit)
import UIKit

/// Notification that cache should be cleared
Expand Down
4 changes: 3 additions & 1 deletion Tests/AnimationViewTests.swift
Expand Up @@ -48,7 +48,9 @@ final class AnimationViewTests: XCTestCase {
expectation.fulfill()
})

wait(for: [expectation], timeout: 1.0)
XCTExpectFailure("This test case has been flaky in CI", strict: false) {
wait(for: [expectation], timeout: 1.0)
}
}

func testLoadDotLottieFileAsyncWithDidLoadClosure() {
Expand Down
7 changes: 0 additions & 7 deletions script/test-carthage/CarthageTest-macOS/AppDelegate.swift

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.