Skip to content

Commit

Permalink
Test example app under more Xcode versions
Browse files Browse the repository at this point in the history
  • Loading branch information
calda committed Jan 12, 2024
1 parent f4da9b1 commit 99657f1
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 30 deletions.
47 changes: 42 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

jobs:
Test-package-macos-13:
test-package-excluding-visionOS:
name: "Test Package"
runs-on: macos-13
strategy:
Expand All @@ -17,8 +17,23 @@ jobs:
- '14.2' # Swift 5.7
- '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)
- '15.1' # Swift 5.9
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
Expand All @@ -27,9 +42,31 @@ 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
- '15.1' # 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
Expand Down
4 changes: 0 additions & 4 deletions Example/Example/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,3 @@ struct ContentView: View {
}
}
}

#Preview {
ContentView()
}
22 changes: 10 additions & 12 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@

import PackageDescription

// TODO: What Xcode versions are able to consume this?
// Both versions use the exact same Swift version (5.9.2).
//#if compiler(>=5.9)
/// A precompiled XCFramework of the lottie-ios repo that was compiled with Xcode 15.2 / Swift 5.9.2.
#if compiler(>=5.9)
/// A precompiled XCFramework of the lottie-ios repo that was compiled with Xcode 15.2 / Swift 5.9.
let lottieXCFramework = Target.binaryTarget(
name: "Lottie",
path: "Lottie-vision-os-test-do-not-use.xcframework")

//#else
#else
/// TODO: Update to Lottie 4.4.0
/// A precompiled XCFramework of the lottie-ios repo that was compiled with Xcode 14.1.
//let lottieXCFramework = Target.binaryTarget(
// name: "Lottie",
// url: "https://github.com/airbnb/lottie-ios/releases/download/4.3.4/Lottie.xcframework.zip",
// checksum: "33c4efc87130f751e8a4bee1de5c557c6821566e05d0fa77cdcc1beae23858ca")
//#endif
/// A precompiled XCFramework of the lottie-ios repo that was compiled with Xcode 14.1 / Swift 5.7.
let lottieXCFramework = Target.binaryTarget(
name: "Lottie",
url: "https://github.com/airbnb/lottie-ios/releases/download/4.3.4/Lottie.xcframework.zip",
checksum: "33c4efc87130f751e8a4bee1de5c557c6821566e05d0fa77cdcc1beae23858ca")
#endif


let package = Package(
Expand All @@ -32,6 +29,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(
Expand Down
49 changes: 40 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +54,7 @@ namespace :test do
desc 'Tests the Lottie package for supported platforms'
namespace :package do
desc 'Tests the Lottie package for all supported platforms'
task all: ['iOS', 'macOS', 'tvOS']
task all: ['iOS', 'macOS', 'tvOS', 'visionOS']

desc 'Tests the Lottie package for iOS'
task :iOS do
Expand All @@ -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

Expand All @@ -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

0 comments on commit 99657f1

Please sign in to comment.