Skip to content

Commit

Permalink
Fix swift concurrency flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Jul 1, 2024
1 parent 5ada3f3 commit 3b7e29c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import class Foundation.ProcessInfo
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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UserNotifications


/// Get notified about receiving notifications.
public protocol NotificationHandler {
public protocol NotificationHandler { // TODO: really all MainActor?

Check failure on line 13 in Sources/Spezi/Capabilities/Notifications/NotificationHandler.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (really all MainActor?) (todo)
#if !os(tvOS)
/// Handle user-selected notification action.
///
Expand All @@ -22,6 +22,7 @@ public protocol NotificationHandler {
/// - Note: Notification Actions are not supported on `tvOS`.
///
/// - Parameter response: The user's response to the notification.
@MainActor
func handleNotificationAction(_ response: UNNotificationResponse) async
#endif

Expand All @@ -35,6 +36,7 @@ public protocol NotificationHandler {
///
/// - Parameter notification: The notification that is about to be delivered.
/// - Returns: The option for notifying the user. Use `[]` to silence the notification.
@MainActor
func receiveIncomingNotification(_ notification: UNNotification) async -> UNNotificationPresentationOptions?

#if !os(macOS)
Expand All @@ -51,6 +53,7 @@ public protocol NotificationHandler {
///
/// - Parameter remoteNotification: The data of the notification payload.
/// - Returns: Return the respective ``BackgroundFetchResult``.
@MainActor
func receiveRemoteNotification(_ remoteNotification: [AnyHashable: Any]) async -> BackgroundFetchResult
#else
/// Handle remote notification when the app is running in background.
Expand All @@ -62,6 +65,7 @@ public protocol NotificationHandler {
/// [`application(_:didReceiveRemoteNotification:)`](https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428430-application).
///
/// - Parameter remoteNotification: The data of the notification payload.
@MainActor
func receiveRemoteNotification(_ remoteNotification: [AnyHashable: Any])
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SpeziFoundation
import SwiftUI


private final class RemoteNotificationContinuation: DefaultProvidingKnowledgeSource {
private final class RemoteNotificationContinuation: DefaultProvidingKnowledgeSource, @unchecked Sendable {
typealias Anchor = SpeziAnchor

static let defaultValue = RemoteNotificationContinuation()
Expand Down
10 changes: 6 additions & 4 deletions Sources/Spezi/Spezi/Spezi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


import OrderedCollections
import os
import OSLog
import SpeziFoundation
import SwiftUI
import XCTRuntimeAssertions
Expand Down Expand Up @@ -120,8 +120,10 @@ struct WeaklyStoredModule<M: Module>: KnowledgeSource {
/// - ``unregisterRemoteNotifications``
@Observable
public class Spezi {
static let logger = Logger(subsystem: "edu.stanford.spezi", category: "Spezi")

static var logger: Logger {
Logger(subsystem: "edu.stanford.spezi", category: "Spezi")
}

@TaskLocal static var moduleInitContext: ModuleDescription?

let standard: any Standard
Expand Down Expand Up @@ -341,7 +343,7 @@ public class Spezi {
// supply modules values to all @Collect
module.injectModuleValues(from: storage)

module.configure()
module.configure() // TODO: do we want to guarantee @MainActor?

Check failure on line 346 in Sources/Spezi/Spezi/Spezi.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (do we want to guarantee @maina...) (todo)

switch ownership {
case .spezi:
Expand Down
1 change: 0 additions & 1 deletion Sources/Spezi/Spezi/SpeziNotificationCenterDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class SpeziNotificationCenterDelegate: NSObject, UNUserNotificationCenterDelegate {
#if !os(tvOS)

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
await withTaskGroup(of: Void.self) { @MainActor group in
// Moving this inside here (@MainActor isolated task group body) helps us avoid making the whole delegate method @MainActor.
Expand Down
1 change: 1 addition & 0 deletions Sources/Spezi/Spezi/View+Spezi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extension View {
/// Configure Spezi for your application using a delegate.
/// - Parameter delegate: The ``SpeziAppDelegate`` used in the SwiftUI App instance.
/// - Returns: The configured view using the Spezi framework.
@MainActor
public func spezi(_ delegate: SpeziAppDelegate) -> some View {
modifier(SpeziViewModifier(delegate.spezi))
}
Expand Down

0 comments on commit 3b7e29c

Please sign in to comment.