From 6480d5e70ab809569c27e9542523739e3e3d3958 Mon Sep 17 00:00:00 2001 From: Cal Stephens Date: Thu, 11 Jan 2024 16:12:55 -0800 Subject: [PATCH] Test example app under more Xcode versions --- .github/workflows/main.yml | 44 +++++++++++++++++++++++++++++++---- Package.swift | 1 + Rakefile | 47 +++++++++++++++++++++++++++++++------- 3 files changed, 80 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d6b88d0..fb5c07d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ on: branches: [ main ] jobs: - Test-package-macos-13: + test-package-excluding-visionOS: name: "Test Package" runs-on: macos-13 strategy: @@ -18,7 +18,22 @@ jobs: - '14.3' # Swift 5.8 - '15.0' # Swift 5.9 - '15.1' # Swift 5.9.2 - - '15.2' # Swift 5.9.2 (first version with visionOS support, TODO: also test visionOS build) + steps: + - uses: actions/checkout@v2 + - uses: ./.github/actions/setup + with: + xcode: ${{ matrix.xcode }} + - name: Build Package + run: SKIP_VISION_OS=true bundle exec rake test:package:all + + test-package-macos-13: + name: "Test Package" + runs-on: macos-13 + strategy: + fail-fast: false + matrix: + xcode: + - '15.2' # Swift 5.9, first version with visionOS support steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup @@ -27,9 +42,30 @@ jobs: - name: Build Package run: bundle exec rake test:package:all - build-example: + build-example-excluding-visionOS: + name: "Build Example App" + runs-on: macos-13 + strategy: + fail-fast: false + matrix: + xcode: + - '14.2' # Swift 5.7 + - '14.3' # Swift 5.8 + - '15.0' # Swift 5.9 + steps: + - uses: actions/checkout@v2 + - uses: ./.github/actions/setup + - name: Build Example + run: SKIP_VISION_OS=true bundle exec rake build:example:github_actions + + build-example-macos-13: name: "Build Example App" - runs-on: macos-12 + runs-on: macos-13 + strategy: + fail-fast: false + matrix: + xcode: + - '15.2' # Swift 5.9, first version with visionOS support steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup diff --git a/Package.swift b/Package.swift index 89fc78b..c0b7ed9 100644 --- a/Package.swift +++ b/Package.swift @@ -32,6 +32,7 @@ let package = Package( // Lottie from being embedded in the app product, causing the app to crash when // ran on a physical device. As a workaround, we can include a stub target // with at least one source file. + // https://github.com/apple/swift-package-manager/issues/6069 .target(name: "_LottieStub"), .testTarget( diff --git a/Rakefile b/Rakefile index 0078573..cea9e8a 100644 --- a/Rakefile +++ b/Rakefile @@ -2,35 +2,49 @@ namespace :build do desc 'Builds the Lottie example app' namespace :example do desc 'Builds the Example apps for all supported platforms / architectures. Requires valid code signing.' - task all: ['iOS:simulator', 'iOS:device', 'macOS:arm64', 'macOS:x86_64', 'macCatalyst:arm64', 'macCatalyst:x86_64'] + task all: ['iOS:simulator', 'iOS:device', 'tvOS:simulator', 'visionOS:simulator', 'macOS:arm64', 'macOS:x86_64', 'macCatalyst:arm64', 'macCatalyst:x86_64'] desc 'Builds the Example app for platforms / architectures supported by Github Actions CI' - task github_actions: ['iOS:simulator', 'macOS:x86_64'] + task github_actions: ['iOS:simulator', 'tvOS:simulator', 'visionOS:simulator', 'macOS:x86_64'] namespace :iOS do task :simulator do - xcodebuild('build -scheme "Example (iOS)" -destination "platform=iOS Simulator,name=iPhone SE (3rd generation)" -workspace Example/Example.xcworkspace') + xcodebuild('build -scheme "Example" -destination "platform=iOS Simulator,name=iPhone SE (3rd generation)" -workspace Example/Example.xcworkspace') end task :device do - xcodebuild('build -scheme "Example (iOS)" -destination generic/platform=iOS -workspace Example/Example.xcworkspace') + xcodebuild('build -scheme "Example" -destination generic/platform=iOS -workspace Example/Example.xcworkspace') + end + end + + namespace :tvOS do + task :simulator do + xcodebuild('build -scheme "Example" -destination "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)" -workspace Example/Example.xcworkspace') + end + end + + namespace :visionOS do + task :simulator do + ifVisionOSEnabled { + xcodebuild('build -scheme "Example" -destination "platform=visionOS Simulator,name=Apple Vision Pro" -workspace Example/Example.xcworkspace') + } end end namespace :macOS do task :arm64 do - xcodebuild('build -scheme "Example (macOS)" -destination "platform=macOS,arch=arm64" -workspace Example/Example.xcworkspace') + xcodebuild('build -scheme "Example" -destination "platform=macOS,arch=arm64" -workspace Example/Example.xcworkspace') end task :x86_64 do - xcodebuild('build -scheme "Example (macOS)" -destination "platform=macOS,arch=x86_64" -workspace Example/Example.xcworkspace') + xcodebuild('build -scheme "Example" -destination "platform=macOS,arch=x86_64" -workspace Example/Example.xcworkspace') end end namespace :macCatalyst do task :arm64 do - xcodebuild('build -scheme "Example (iOS)" -destination "platform=macOS,variant=Mac Catalyst,arch=arm64" -workspace Example/Example.xcworkspace') + xcodebuild('build -scheme "Example" -destination "platform=macOS,variant=Mac Catalyst,arch=arm64" -workspace Example/Example.xcworkspace') end task :x86_64 do - xcodebuild('build -scheme "Example (iOS)" -destination "platform=macOS,variant=Mac Catalyst,arch=x86_64" -workspace Example/Example.xcworkspace') + xcodebuild('build -scheme "Example" -destination "platform=macOS,variant=Mac Catalyst,arch=x86_64" -workspace Example/Example.xcworkspace') end end end @@ -56,6 +70,13 @@ namespace :test do task :tvOS do xcodebuild('test -scheme Lottie -destination "platform=tvOS Simulator,name=Apple TV"') end + + desc 'Tests the Lottie package for visionOS' + task :visionOS do + ifVisionOSEnabled { + xcodebuild('test -scheme Lottie -destination "platform=visionOS Simulator,name=Apple Vision Pro"') + } + end end end @@ -69,3 +90,13 @@ def xcodebuild(command) sh "xcodebuild #{command}" end end + +# Runs the given code block, unless `SKIP_VISION_OS=true`. +# This can be removed once CI only uses Xcode 15+. +def ifVisionOSEnabled + if ENV["SKIP_VISION_OS"] == "true" + puts "Skipping visionOS build" + else + yield + end +end