From 7d1c8ff8310e2f628f918fb535d80f368730ad6b Mon Sep 17 00:00:00 2001 From: Philipp Zagar Date: Fri, 1 Mar 2024 12:00:08 -0800 Subject: [PATCH] Add VisionOS and macOS support (#18) # Add VisionOS and macOS support ## :recycle: Current situation & Problem Currently, SpeziStorage only supports iOS platforms, leading to issues with depending on packages that use the package and want to support a broad variety of packages. ## :gear: Release Notes - Add VisionOS and macOS support ## :books: Documentation -- ## :white_check_mark: Testing CI steps to ensure building & launching on the respective platforms. ## :pencil: Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md). --- .github/workflows/build-and-test.yml | 120 ++++++++++++++++-- CONTRIBUTORS.md | 1 + Package.swift | 8 +- .../LocalStorageTests.swift | 5 + Tests/UITests/TestApp/TestApp.swift | 3 +- .../UITests/UITests.xcodeproj/project.pbxproj | 24 +++- 6 files changed, 141 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ff807e3..0e1b5a6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,7 +1,7 @@ # -# This source file is part of the Stanford Spezi open-source project +# This source file is part of the Stanford Spezi open source project # -# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +# SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) # # SPDX-License-Identifier: MIT # @@ -16,24 +16,124 @@ on: workflow_dispatch: jobs: - buildandtest: - name: Build and Test Swift Package + buildandtest_ios: + name: Build and Test Swift Package iOS uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + strategy: + matrix: + include: + - buildConfig: Debug + artifactname: SpeziStorage-Package-iOS.xcresult + resultBundle: SpeziStorage-Package-iOS.xcresult + - buildConfig: Release + artifactname: SpeziStorage-Package-iOS-Release.xcresult + resultBundle: SpeziStorage-Package-iOS-Release.xcresult with: - artifactname: SpeziStorage-Package.xcresult runsonlabels: '["macOS", "self-hosted"]' scheme: SpeziStorage-Package - buildandtestuitests: - name: Build and Test UI Tests + buildConfig: ${{ matrix.buildConfig }} + resultBundle: ${{ matrix.resultBundle }} + artifactname: ${{ matrix.artifactname }} + buildandtest_visionos: + name: Build and Test Swift Package visionOS uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + strategy: + matrix: + include: + - buildConfig: Debug + artifactname: SpeziStorage-Package-visionOS.xcresult + resultBundle: SpeziStorage-Package-visionOS.xcresult + - buildConfig: Release + artifactname: SpeziStorage-Package-visionOS-Release.xcresult + resultBundle: SpeziStorage-Package-visionOS-Release.xcresult + with: + runsonlabels: '["macOS", "self-hosted"]' + scheme: SpeziStorage-Package + destination: 'platform=visionOS Simulator,name=Apple Vision Pro' + buildConfig: ${{ matrix.buildConfig }} + resultBundle: ${{ matrix.resultBundle }} + artifactname: ${{ matrix.artifactname }} + buildandtest_macos: + name: Build and Test Swift Package macOS + uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + strategy: + matrix: + include: + - buildConfig: Debug + artifactname: SpeziStorage-Package-macOS.xcresult + resultBundle: SpeziStorage-Package-macOS.xcresult + - buildConfig: Release + artifactname: SpeziStorage-Package-macOS-Release.xcresult + resultBundle: SpeziStorage-Package-macOS-Release.xcresult + with: + runsonlabels: '["macOS", "self-hosted"]' + scheme: SpeziStorage-Package + destination: 'platform=macOS,arch=arm64' + buildConfig: ${{ matrix.buildConfig }} + resultBundle: ${{ matrix.resultBundle }} + artifactname: ${{ matrix.artifactname }} + buildandtestuitests_ios: + name: Build and Test UI Tests iOS + uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + strategy: + matrix: + include: + - buildConfig: Debug + resultBundle: TestApp-iOS.xcresult + artifactname: TestApp-iOS.xcresult + - buildConfig: Release + resultBundle: TestApp-iOS-Release.xcresult + artifactname: TestApp-iOS-Release.xcresult + with: + runsonlabels: '["macOS", "self-hosted"]' + path: 'Tests/UITests' + scheme: TestApp + buildConfig: ${{ matrix.buildConfig }} + resultBundle: ${{ matrix.resultBundle }} + artifactname: ${{ matrix.artifactname }} + buildandtestuitests_ipad: + name: Build and Test UI Tests iPadOS + uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + strategy: + matrix: + include: + - buildConfig: Debug + resultBundle: TestApp-iPad.xcresult + artifactname: TestApp-iPad.xcresult + - buildConfig: Release + resultBundle: TestApp-iPad-Release.xcresult + artifactname: TestApp-iPad-Release.xcresult + with: + runsonlabels: '["macOS", "self-hosted"]' + path: 'Tests/UITests' + scheme: TestApp + destination: 'platform=iOS Simulator,name=iPad Air (5th generation)' + buildConfig: ${{ matrix.buildConfig }} + resultBundle: ${{ matrix.resultBundle }} + artifactname: ${{ matrix.artifactname }} + buildandtestuitests_visionos: + name: Build and Test UI Tests visionOS + uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + strategy: + matrix: + include: + - buildConfig: Debug + resultBundle: TestApp-visionOS.xcresult + artifactname: TestApp-visionOS.xcresult + - buildConfig: Release + resultBundle: TestApp-visionOS-Release.xcresult + artifactname: TestApp-visionOS-Release.xcresult with: - artifactname: TestApp.xcresult runsonlabels: '["macOS", "self-hosted"]' path: 'Tests/UITests' scheme: TestApp + destination: 'platform=visionOS Simulator,name=Apple Vision Pro' + buildConfig: ${{ matrix.buildConfig }} + resultBundle: ${{ matrix.resultBundle }} + artifactname: ${{ matrix.artifactname }} uploadcoveragereport: name: Upload Coverage Report - needs: [buildandtest, buildandtestuitests] + needs: [buildandtest_ios, buildandtest_visionos, buildandtest_macos, buildandtestuitests_ios, buildandtestuitests_ipad, buildandtestuitests_visionos] uses: StanfordSpezi/.github/.github/workflows/create-and-upload-coverage-report.yml@v2 with: - coveragereports: SpeziStorage-Package.xcresult TestApp.xcresult + coveragereports: 'SpeziStorage-Package-iOS.xcresult SpeziStorage-Package-visionOS.xcresult SpeziStorage-Package-macOS.xcresult TestApp-iOS.xcresult TestApp-iPad.xcresult TestApp-visionOS.xcresult' \ No newline at end of file diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index fbfb8ff..5ce404d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -14,3 +14,4 @@ SpeziStorage contributors * [Paul Schmiedmayer](https://github.com/PSchmiedmayer) * [Vishnu Ravi](https://github.com/vishnuravi) * [Andreas Bauer](https://github.com/Supereg) +* [Philipp Zagar]https://github.com/philippzagar) diff --git a/Package.swift b/Package.swift index 7753fdb..4e5ef40 100644 --- a/Package.swift +++ b/Package.swift @@ -14,15 +14,17 @@ import PackageDescription let package = Package( name: "SpeziStorage", platforms: [ - .iOS(.v17) + .iOS(.v17), + .visionOS(.v1), + .macOS(.v14) ], products: [ .library(name: "SpeziLocalStorage", targets: ["SpeziLocalStorage"]), .library(name: "SpeziSecureStorage", targets: ["SpeziSecureStorage"]) ], dependencies: [ - .package(url: "https://github.com/StanfordSpezi/Spezi", from: "1.0.0"), - .package(url: "https://github.com/StanfordBDHG/XCTRuntimeAssertions", from: "1.0.0") + .package(url: "https://github.com/StanfordSpezi/Spezi", from: "1.2.1"), + .package(url: "https://github.com/StanfordBDHG/XCTRuntimeAssertions", from: "1.0.1") ], targets: [ .target( diff --git a/Tests/SpeziLocalStorageTests/LocalStorageTests.swift b/Tests/SpeziLocalStorageTests/LocalStorageTests.swift index 1730cc2..d4170c6 100644 --- a/Tests/SpeziLocalStorageTests/LocalStorageTests.swift +++ b/Tests/SpeziLocalStorageTests/LocalStorageTests.swift @@ -26,7 +26,12 @@ final class LocalStorageTests: XCTestCase { func testLocalStorage() async throws { + #if !os(macOS) let spezi = await LocalStorageTestsAppDelegate().spezi + #else + let spezi = LocalStorageTestsAppDelegate().spezi + #endif + let localStorage = try XCTUnwrap(spezi.storage[LocalStorage.self]) let letter = Letter(greeting: "Hello Paul 👋\(String(repeating: "🚀", count: Int.random(in: 0...10)))") diff --git a/Tests/UITests/TestApp/TestApp.swift b/Tests/UITests/TestApp/TestApp.swift index fe8408c..2276f79 100644 --- a/Tests/UITests/TestApp/TestApp.swift +++ b/Tests/UITests/TestApp/TestApp.swift @@ -6,12 +6,13 @@ // SPDX-License-Identifier: MIT // +import Spezi import SwiftUI import XCTestApp @main struct UITestsApp: App { - @UIApplicationDelegateAdaptor(TestAppDelegate.self) var appDelegate + @ApplicationDelegateAdaptor(TestAppDelegate.self) var appDelegate var body: some Scene { diff --git a/Tests/UITests/UITests.xcodeproj/project.pbxproj b/Tests/UITests/UITests.xcodeproj/project.pbxproj index b170dc7..17045c6 100644 --- a/Tests/UITests/UITests.xcodeproj/project.pbxproj +++ b/Tests/UITests/UITests.xcodeproj/project.pbxproj @@ -438,10 +438,12 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.spezi.storage.testapp; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; }; name = Debug; }; @@ -469,10 +471,12 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.spezi.storage.testapp; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; }; name = Release; }; @@ -489,10 +493,12 @@ PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.spezi.storage.testappuitests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; TEST_TARGET_NAME = TestApp; }; name = Debug; @@ -510,9 +516,11 @@ PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.spezi.storage.testappuitests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; TEST_TARGET_NAME = TestApp; }; name = Release; @@ -601,10 +609,12 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.spezi.storage.testapp; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; }; name = Test; }; @@ -621,10 +631,12 @@ PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.spezi.storage.testappuitests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; TEST_TARGET_NAME = TestApp; }; name = Test;