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

Migrate to @_spi instead of @testable #101

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions Sources/Spezi/Module/ModuleCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
///
/// You can not create a ``ModuleCollection`` yourself. Please use the ``ModuleBuilder`` to create a ``ModuleCollection``.
public class ModuleCollection {
let elements: [any Module]

/// The elements of the collection.
@_spi(Spezi)
public let elements: [any Module]


init(elements: [any Module]) {
self.elements = elements
Expand Down
14 changes: 7 additions & 7 deletions Sources/Spezi/Spezi/KnowledgeSources/LaunchOptionsKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
import SpeziFoundation
import SwiftUI


struct LaunchOptionsKey: DefaultProvidingKnowledgeSource {
typealias Anchor = SpeziAnchor
@_spi(Spezi)
public struct LaunchOptionsKey: DefaultProvidingKnowledgeSource {
public typealias Anchor = SpeziAnchor

#if os(iOS) || os(visionOS) || os(tvOS)
typealias Value = [UIApplication.LaunchOptionsKey: Any]
public typealias Value = [UIApplication.LaunchOptionsKey: Any]
#elseif os(macOS)
/// Currently not supported as ``SpeziAppDelegate/applicationWillFinishLaunching(_:)`` on macOS
/// is executed after the initialization of ``Spezi`` via `View/spezi(_:)` is done, breaking our initialization assumption in ``SpeziAppDelegate/applicationWillFinishLaunching(_:)``.
typealias Value = [Never: Any]
public typealias Value = [Never: Any]
#else // os(watchOS)
typealias Value = [Never: Any]
public typealias Value = [Never: Any]
#endif

static let defaultValue: Value = [:]
public static let defaultValue: Value = [:]
}


Expand Down
13 changes: 11 additions & 2 deletions Sources/Spezi/Spezi/Spezi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public class Spezi {
)


var lifecycleHandler: [LifecycleHandler] {
@_spi(Spezi)
public var lifecycleHandler: [LifecycleHandler] {
storage.collect(allOf: LifecycleHandler.self)
}

Expand All @@ -108,7 +109,15 @@ public class Spezi {
self.init(standard: configuration.standard, modules: configuration.modules.elements, storage: storage)
}

init(

/// Create a new Spezi instance.
///
/// - Parameters:
/// - standard: The standard to use.
/// - modules: The collection of modules to initialize.
/// - storage: Optional, initial storage to inject.
@_spi(Spezi)
public init(
standard: any Standard,
modules: [any Module],
storage: consuming SpeziStorage = SpeziStorage()
Expand Down
5 changes: 4 additions & 1 deletion Sources/Spezi/Standard/DefaultStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
//


actor DefaultStandard: Standard {}
@_spi(Spezi)
public actor DefaultStandard: Standard {
public init() {}
}
4 changes: 2 additions & 2 deletions Sources/XCTSpezi/DependencyResolution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// SPDX-License-Identifier: MIT
//

@testable import Spezi
@_implementationOnly import SwiftUI
@_spi(Spezi) import Spezi
import SwiftUI


/// Configure and resolve the dependency tree for a collection of [`Module`](https://swiftpackageindex.com/stanfordspezi/spezi/documentation/spezi/module)s.
Expand Down
2 changes: 1 addition & 1 deletion Tests/SpeziTests/ModuleTests/ModuleBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// SPDX-License-Identifier: MIT
//

@testable import Spezi
@testable @_spi(Spezi) import Spezi
import XCTest
import XCTRuntimeAssertions

Expand Down
Loading