From 2f03345ee15d7104f226473c2fe19c23b5fbd252 Mon Sep 17 00:00:00 2001 From: Paul Schmiedmayer Date: Sat, 29 Jun 2024 00:04:15 -0700 Subject: [PATCH 1/2] Update to ResearchKitOnFHIR 2.0 --- Package.swift | 48 +++++++++++++++++-- .../UITests/UITests.xcodeproj/project.pbxproj | 37 +++----------- .../xcshareddata/xcschemes/TestApp.xcscheme | 2 +- 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/Package.swift b/Package.swift index 0e0513e..8f0a124 100644 --- a/Package.swift +++ b/Package.swift @@ -8,9 +8,17 @@ // SPDX-License-Identifier: MIT // +import class Foundation.ProcessInfo import PackageDescription +#if swift(<6) +let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("SwiftConcurrency") +#else +let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("SwiftConcurrency") +#endif + + let package = Package( name: "SpeziQuestionnaire", defaultLocalization: "en", @@ -26,8 +34,8 @@ let package = Package( .package(url: "https://github.com/StanfordSpezi/SpeziViews", from: "1.0.0"), .package(url: "https://github.com/apple/FHIRModels", .upToNextMinor(from: "0.5.0")), .package(url: "https://github.com/StanfordBDHG/ResearchKit", from: "3.0.1"), - .package(url: "https://github.com/StanfordBDHG/ResearchKitOnFHIR", from: "1.4.0") - ], + .package(url: "https://github.com/StanfordBDHG/ResearchKitOnFHIR", from: "2.0.0") + ] + swiftLintPackage(), targets: [ .target( name: "SpeziQuestionnaire", @@ -38,13 +46,21 @@ let package = Package( .product(name: "FHIRQuestionnaires", package: "ResearchKitOnFHIR"), .product(name: "ResearchKit", package: "ResearchKit"), .product(name: "ResearchKitSwiftUI", package: "ResearchKit") - ] + ], + swiftSettings: [ + swiftConcurrency + ], + plugins: [] + swiftLintPlugin() ), .testTarget( name: "SpeziQuestionnaireTests", dependencies: [ .target(name: "SpeziQuestionnaire") - ] + ], + swiftSettings: [ + swiftConcurrency + ], + plugins: [] + swiftLintPlugin() ), .target( name: "SpeziTimedWalkTest", @@ -52,7 +68,29 @@ let package = Package( .product(name: "Spezi", package: "Spezi"), .product(name: "SpeziViews", package: "SpeziViews"), .product(name: "ModelsR4", package: "FHIRModels") - ] + ], + swiftSettings: [ + swiftConcurrency + ], + plugins: [] + swiftLintPlugin() ) ] ) + + +func swiftLintPlugin() -> [Target.PluginUsage] { + // Fully quit Xcode and open again with `open --env SPEZI_DEVELOPMENT_SWIFTLINT /Applications/Xcode.app` + if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil { + [.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint")] + } else { + [] + } +} + +func swiftLintPackage() -> [PackageDescription.Package.Dependency] { + if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil { + [.package(url: "https://github.com/realm/SwiftLint.git", .upToNextMinor(from: "0.55.1"))] + } else { + [] + } +} diff --git a/Tests/UITests/UITests.xcodeproj/project.pbxproj b/Tests/UITests/UITests.xcodeproj/project.pbxproj index 067db67..dc78067 100644 --- a/Tests/UITests/UITests.xcodeproj/project.pbxproj +++ b/Tests/UITests/UITests.xcodeproj/project.pbxproj @@ -122,12 +122,10 @@ 2F6D138E28F5F384007C25D6 /* Sources */, 2F6D138F28F5F384007C25D6 /* Frameworks */, 2F6D139028F5F384007C25D6 /* Resources */, - 395F861C2A6B5AEE00C5D578 /* ShellScript */, ); buildRules = ( ); dependencies = ( - 4A3D9D772AF310FC00AE3078 /* PBXTargetDependency */, ); name = TestApp; packageProductDependencies = ( @@ -164,7 +162,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1410; - LastUpgradeCheck = 1520; + LastUpgradeCheck = 1600; TargetAttributes = { 2F6D139128F5F384007C25D6 = { CreatedOnToolsVersion = 14.1; @@ -214,27 +212,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 395F861C2A6B5AEE00C5D578 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftlint > /dev/null; then\n cd ../../ && swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 2F6D138E28F5F384007C25D6 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -263,9 +240,6 @@ target = 2F6D139128F5F384007C25D6 /* TestApp */; targetProxy = 2F6D13AD28F5F386007C25D6 /* PBXContainerItemProxy */; }; - 4A3D9D772AF310FC00AE3078 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -306,6 +280,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -327,6 +302,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_STRICT_CONCURRENCY = complete; }; name = Debug; }; @@ -367,6 +343,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -381,6 +358,7 @@ SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_STRICT_CONCURRENCY = complete; VALIDATE_PRODUCT = YES; }; name = Release; @@ -470,7 +448,6 @@ 2F6D13BD28F5F386007C25D6 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 64FJ2MWNP4; @@ -489,7 +466,6 @@ 2F6D13BE28F5F386007C25D6 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 64FJ2MWNP4; @@ -542,6 +518,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -563,6 +540,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = TEST; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_STRICT_CONCURRENCY = complete; }; name = Test; }; @@ -609,7 +587,6 @@ 2FB07589299DDB6000C0B37F /* Test */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 64FJ2MWNP4; diff --git a/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme b/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme index 19a15c8..a839ff9 100644 --- a/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme +++ b/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme @@ -1,6 +1,6 @@ Date: Sat, 29 Jun 2024 00:09:36 -0700 Subject: [PATCH 2/2] Update Tests --- Tests/UITests/TestAppUITests/TestAppUITests.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/UITests/TestAppUITests/TestAppUITests.swift b/Tests/UITests/TestAppUITests/TestAppUITests.swift index 0e49252..daa8a31 100644 --- a/Tests/UITests/TestAppUITests/TestAppUITests.swift +++ b/Tests/UITests/TestAppUITests/TestAppUITests.swift @@ -10,12 +10,14 @@ import XCTest class TestAppUITests: XCTestCase { + @MainActor override func setUpWithError() throws { try super.setUpWithError() continueAfterFailure = false } + @MainActor func testSpeziQuestionnaire() throws { let app = XCUIApplication() app.launch() @@ -53,6 +55,7 @@ class TestAppUITests: XCTestCase { XCTAssert(app.staticTexts["No. of surveys complete: 1"].waitForExistence(timeout: 2)) } + @MainActor func testSpeziTimedWalkTest() throws { let app = XCUIApplication() app.launch()