Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide integration points for SpeziNotifications, Swift 6 and silence some warnings #117

Merged
merged 25 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b688b43
Allow `@Application` in SwiftUI views and additional notifications su…
Supereg Sep 13, 2024
c4cbf0c
Align the structure and update documentation
Supereg Sep 13, 2024
ba32953
Add LocalNotifications module
Supereg Sep 13, 2024
1194e2f
Compatibility with Swift 5 toolchain
Supereg Sep 13, 2024
2a9ddc7
More compatibility
Supereg Sep 13, 2024
a661cce
Support querying pending and delivered notifications
Supereg Sep 16, 2024
14513af
Update urls
Supereg Sep 17, 2024
ad6ffcd
Restore compatibility with other platforms
Supereg Sep 17, 2024
9b8f3e4
Enable Swift 6 language mode
Supereg Sep 17, 2024
c4aa84f
Remove latest workflows
Supereg Sep 17, 2024
9ac1bc1
Also apply to implementation
Supereg Sep 17, 2024
3c9a92f
Fix Swift 6 compatibility of unit tests
Supereg Sep 17, 2024
d89a3a1
Use Swift 6 Language mode for UI tests as well
Supereg Sep 17, 2024
7039019
Be less restrictive
Supereg Sep 19, 2024
7f6a2b9
Retrieve spezi from the view environment
Supereg Sep 20, 2024
443bf5c
Remove Notification realted infrastructure again. Moving to SpeziNoti…
Supereg Sep 28, 2024
e55c7b5
Minor changes
Supereg Sep 28, 2024
cbbe126
Minor fixes
Supereg Sep 28, 2024
c73eaaa
Regactor some infrastructure
Supereg Sep 30, 2024
f502ed2
Make APISupport Spezi access static
Supereg Sep 30, 2024
6aa8e4d
Some swiftlint
Supereg Sep 30, 2024
dd59b84
Docs changes
Supereg Oct 14, 2024
3752b6d
Introduce DependencyManagerError
Supereg Oct 28, 2024
b536a87
Introduce error hierarchy
Supereg Oct 28, 2024
b723a0a
Add links
Supereg Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ jobs:
scheme: Spezi-Package
resultBundle: Spezi-Package-iOS.xcresult
artifactname: Spezi-Package-iOS.xcresult
buildandtest_ios_latest:
name: Build and Test Swift Package iOS Latest
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: Spezi-Package
xcodeversion: latest
swiftVersion: 6
resultBundle: Spezi-Package-iOS-Latest.xcresult
artifactname: Spezi-Package-iOS-Latest.xcresult
buildandtest_watchos:
name: Build and Test Swift Package watchOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
Expand Down Expand Up @@ -79,17 +69,6 @@ jobs:
scheme: TestApp
resultBundle: TestApp-iOS.xcresult
artifactname: TestApp-iOS.xcresult
buildandtestuitests_ios_latest:
name: Build and Test UI Tests iOS Latest
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: Tests/UITests
scheme: TestApp
xcodeversion: latest
swiftVersion: 6
resultBundle: TestApp-iOS-Latest.xcresult
artifactname: TestApp-iOS-Latest.xcresult
buildandtestuitests_visionos:
name: Build and Test UI Tests visionOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
Expand Down
1 change: 1 addition & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ builder:
configs:
- platform: ios
scheme: Spezi
swift_version: 6
documentation_targets:
- Spezi
- XCTSpezi
21 changes: 3 additions & 18 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0

//
// This source file is part of the Stanford Spezi open-source project
Expand All @@ -11,12 +11,6 @@
import class Foundation.ProcessInfo
import PackageDescription

#if swift(<6)
let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("StrictConcurrency")
#else
let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("StrictConcurrency")
#endif


let package = Package(
name: "Spezi",
Expand All @@ -33,8 +27,8 @@ let package = Package(
.library(name: "XCTSpezi", targets: ["XCTSpezi"])
],
dependencies: [
.package(url: "https://github.com/StanfordSpezi/SpeziFoundation", from: "2.0.0-beta.1"),
.package(url: "https://github.com/StanfordBDHG/XCTRuntimeAssertions", from: "1.1.1"),
.package(url: "https://github.com/StanfordSpezi/SpeziFoundation.git", from: "2.0.0"),
.package(url: "https://github.com/StanfordBDHG/XCTRuntimeAssertions.git", from: "1.1.1"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.1")
] + swiftLintPackage(),
targets: [
Expand All @@ -45,19 +39,13 @@ let package = Package(
.product(name: "XCTRuntimeAssertions", package: "XCTRuntimeAssertions"),
.product(name: "OrderedCollections", package: "swift-collections")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "XCTSpezi",
dependencies: [
.target(name: "Spezi")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
),
.testTarget(
Expand All @@ -67,9 +55,6 @@ let package = Package(
.target(name: "XCTSpezi"),
.product(name: "XCTRuntimeAssertions", package: "XCTRuntimeAssertions")
],
swiftSettings: [
swiftConcurrency
],
plugins: [] + swiftLintPlugin()
)
]
Expand Down
29 changes: 17 additions & 12 deletions Sources/Spezi/Capabilities/ApplicationPropertyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
// SPDX-License-Identifier: MIT
//

import SwiftUI

/// Refer to the documentation of ``Module/Application``.

/// Access a property or action of the Spezi application.
@propertyWrapper
public class _ApplicationPropertyWrapper<Value> { // swiftlint:disable:this type_name
private let keyPath: KeyPath<Spezi, Value>
public struct _ApplicationPropertyWrapper<Value> { // swiftlint:disable:this type_name
private final class State {
weak var spezi: Spezi?
/// Some KeyPaths are declared to copy the value upon injection and not query them every time.
var shadowCopy: Value?
}

private weak var spezi: Spezi?
/// Some KeyPaths are declared to copy the value upon injection and not query them every time.
private var shadowCopy: Value?
private let keyPath: KeyPath<Spezi, Value>
private let state = State()


/// Access the application property.
public var wrappedValue: Value {
if let shadowCopy {
if let shadowCopy = state.shadowCopy {
return shadowCopy
}

guard let spezi else {
guard let spezi = state.spezi else {
preconditionFailure("Underlying Spezi instance was not yet injected. @Application cannot be accessed within the initializer!")
}
return spezi[keyPath: keyPath]
Expand All @@ -39,15 +44,15 @@ public class _ApplicationPropertyWrapper<Value> { // swiftlint:disable:this type

extension _ApplicationPropertyWrapper: SpeziPropertyWrapper {
func inject(spezi: Spezi) {
self.spezi = spezi
state.spezi = spezi
if spezi.createsCopy(keyPath) {
self.shadowCopy = spezi[keyPath: keyPath]
state.shadowCopy = spezi[keyPath: keyPath]
}
}

func clear() {
spezi = nil
shadowCopy = nil
state.spezi = nil
state.shadowCopy = nil
}
}

Expand Down
Loading
Loading