Skip to content

Commit

Permalink
Make APISupport Spezi access static
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Sep 30, 2024
1 parent c73eaaa commit f502ed2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Sources/Spezi/Spezi/SpeziAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,28 @@ open class SpeziAppDelegate: NSObject, ApplicationDelegate, Sendable {
private(set) static weak var appDelegate: SpeziAppDelegate?
static var notificationDelegate: SpeziNotificationCenterDelegate? // swiftlint:disable:this weak_delegate

private(set) var _spezi: Spezi? // swiftlint:disable:this identifier_name

/// Access the Spezi instance.
///
/// Use this property as a basis for creating your own APIs (e.g., providing SwiftUI Environment values that use information from Spezi).
/// To not make it directly available to the user.
@_spi(APISupport)
public var spezi: Spezi {
public static var spezi: Spezi? {
SpeziAppDelegate.appDelegate?._spezi
}

Check warning on line 63 in Sources/Spezi/Spezi/SpeziAppDelegate.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Spezi/Spezi/SpeziAppDelegate.swift#L61-L63

Added lines #L61 - L63 were not covered by tests

private(set) var _spezi: Spezi? // swiftlint:disable:this identifier_name


var spezi: Spezi {
guard let spezi = _spezi else {
let spezi = Spezi(from: configuration)
self._spezi = spezi
return spezi
}
return spezi
}


/// Register your different ``Module``s (or more sophisticated ``Module``s) using the ``SpeziAppDelegate/configuration`` property,.
///
/// The ``Standard`` acts as a central message broker in the application.
Expand Down Expand Up @@ -233,3 +238,4 @@ open class SpeziAppDelegate: NSObject, ApplicationDelegate, Sendable {
}
#endif
}

Check failure on line 241 in Sources/Spezi/Spezi/SpeziAppDelegate.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Trailing Newline Violation: Files should have a single trailing newline (trailing_newline)

0 comments on commit f502ed2

Please sign in to comment.