From d0bd55f8a0bd3eeb806a673261e9d6b9fd43f3cd Mon Sep 17 00:00:00 2001 From: Andreas Bauer Date: Thu, 29 Aug 2024 15:05:45 +0200 Subject: [PATCH] Be less restrictive about the chosen swiftlint version (#28) # Be less restrictive about the chosen swiftlint version ## :recycle: Current situation & Problem This PR loosens the restrictions on the swiftlint version. ## :gear: Release Notes * Allow upToNextMajor swiftlint versions. * Some additional concurrency fixes. ## :books: Documentation -- ## :white_check_mark: Testing -- ## :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). --- Package.swift | 8 ++++---- Sources/SpeziQuestionnaire/Identifier+Identifiable.swift | 6 +++++- Sources/SpeziQuestionnaire/QuestionnaireResult.swift | 3 +++ Sources/SpeziQuestionnaire/QuestionnaireView.swift | 2 +- Sources/SpeziTimedWalkTest/TimedWalkTest.swift | 2 +- .../SpeziTimedWalkTest/TimedWalkTestCompletedView.swift | 7 ++++--- Sources/SpeziTimedWalkTest/TimedWalkTestRunningView.swift | 3 ++- Sources/SpeziTimedWalkTest/TimedWalkTestView.swift | 3 ++- Sources/SpeziTimedWalkTest/TimedWalkTestViewModel.swift | 3 ++- 9 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Package.swift b/Package.swift index 8f0a124..f692353 100644 --- a/Package.swift +++ b/Package.swift @@ -13,9 +13,9 @@ import PackageDescription #if swift(<6) -let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("SwiftConcurrency") +let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("StrictConcurrency") #else -let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("SwiftConcurrency") +let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("StrictConcurrency") #endif @@ -34,7 +34,7 @@ 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: "2.0.0") + .package(url: "https://github.com/StanfordBDHG/ResearchKitOnFHIR", from: "2.0.1") ] + swiftLintPackage(), targets: [ .target( @@ -89,7 +89,7 @@ func swiftLintPlugin() -> [Target.PluginUsage] { 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"))] + [.package(url: "https://github.com/realm/SwiftLint.git", from: "0.55.1")] } else { [] } diff --git a/Sources/SpeziQuestionnaire/Identifier+Identifiable.swift b/Sources/SpeziQuestionnaire/Identifier+Identifiable.swift index d8236e2..936f5c9 100644 --- a/Sources/SpeziQuestionnaire/Identifier+Identifiable.swift +++ b/Sources/SpeziQuestionnaire/Identifier+Identifiable.swift @@ -9,4 +9,8 @@ import ModelsR4 -extension Identifier: Identifiable {} +#if compiler(<6) +extension ModelsR4.Identifier: Swift.Identifiable {} +#else +extension Identifier: @retroactive Identifiable {} +#endif diff --git a/Sources/SpeziQuestionnaire/QuestionnaireResult.swift b/Sources/SpeziQuestionnaire/QuestionnaireResult.swift index 172ff6c..483cb46 100644 --- a/Sources/SpeziQuestionnaire/QuestionnaireResult.swift +++ b/Sources/SpeziQuestionnaire/QuestionnaireResult.swift @@ -18,3 +18,6 @@ public enum QuestionnaireResult { /// The questionnaire task failed due to an error. case failed } + + +extension QuestionnaireResult: Hashable {} diff --git a/Sources/SpeziQuestionnaire/QuestionnaireView.swift b/Sources/SpeziQuestionnaire/QuestionnaireView.swift index 6dff988..6bd4ac2 100644 --- a/Sources/SpeziQuestionnaire/QuestionnaireView.swift +++ b/Sources/SpeziQuestionnaire/QuestionnaireView.swift @@ -40,7 +40,7 @@ public struct QuestionnaireView: View { private static let logger = Logger(subsystem: "edu.stanford.spezi.questionnaire", category: "QuestionnaireView") private let questionnaire: Questionnaire - private let questionnaireResult: (QuestionnaireResult) async -> Void + private let questionnaireResult: @MainActor (QuestionnaireResult) async -> Void private let completionStepMessage: String? private let cancelBehavior: CancelBehavior diff --git a/Sources/SpeziTimedWalkTest/TimedWalkTest.swift b/Sources/SpeziTimedWalkTest/TimedWalkTest.swift index 5e61a6d..18fe84e 100644 --- a/Sources/SpeziTimedWalkTest/TimedWalkTest.swift +++ b/Sources/SpeziTimedWalkTest/TimedWalkTest.swift @@ -10,7 +10,7 @@ import Foundation /// Defines the configuration of a timed walk test. -public struct TimedWalkTest: Codable, Equatable, Hashable { +public struct TimedWalkTest: Codable, Equatable, Hashable, Sendable { /// Default values. public enum Defaults { /// Default timed walk test duration. diff --git a/Sources/SpeziTimedWalkTest/TimedWalkTestCompletedView.swift b/Sources/SpeziTimedWalkTest/TimedWalkTestCompletedView.swift index ae263b3..a39ce52 100644 --- a/Sources/SpeziTimedWalkTest/TimedWalkTestCompletedView.swift +++ b/Sources/SpeziTimedWalkTest/TimedWalkTestCompletedView.swift @@ -39,7 +39,7 @@ struct TimedWalkTestCompletedView: View { Button("Restart", role: .destructive) { dismiss() } - AsyncButton(action: completeAction) { + Button(action: completeAction) { Text("Done") .frame(maxWidth: .infinity, minHeight: 38) } @@ -68,8 +68,9 @@ struct TimedWalkTestCompletedView: View { .bold() .padding() } - - private func completeAction() async { + + @MainActor + private func completeAction() { walkTestViewModel.completeWalkTest() } } diff --git a/Sources/SpeziTimedWalkTest/TimedWalkTestRunningView.swift b/Sources/SpeziTimedWalkTest/TimedWalkTestRunningView.swift index 231197a..ec82016 100644 --- a/Sources/SpeziTimedWalkTest/TimedWalkTestRunningView.swift +++ b/Sources/SpeziTimedWalkTest/TimedWalkTestRunningView.swift @@ -69,7 +69,8 @@ struct TimedWalkTestRunningView: View { .modifier(TimedWalkTestCancelModifier()) } - + + @MainActor private func start() async { withAnimation { prepareCountDown = Date.now.addingTimeInterval(5) diff --git a/Sources/SpeziTimedWalkTest/TimedWalkTestView.swift b/Sources/SpeziTimedWalkTest/TimedWalkTestView.swift index 99bf99c..9799938 100644 --- a/Sources/SpeziTimedWalkTest/TimedWalkTestView.swift +++ b/Sources/SpeziTimedWalkTest/TimedWalkTestView.swift @@ -68,7 +68,8 @@ public struct TimedWalkTestView: View { .environment(walkTestViewModel) } - + + @MainActor public init( timedWalkTest: TimedWalkTest = TimedWalkTest(), completion: @escaping (TimedWalkTestViewResult) -> Void diff --git a/Sources/SpeziTimedWalkTest/TimedWalkTestViewModel.swift b/Sources/SpeziTimedWalkTest/TimedWalkTestViewModel.swift index 72b4c39..f9b4379 100644 --- a/Sources/SpeziTimedWalkTest/TimedWalkTestViewModel.swift +++ b/Sources/SpeziTimedWalkTest/TimedWalkTestViewModel.swift @@ -11,8 +11,9 @@ import Foundation import SwiftUI +@MainActor @Observable -class TimedWalkTestViewModel { +class TimedWalkTestViewModel: Sendable { let pedometer = CMPedometer() let timedWalkTest: TimedWalkTest