generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add global RuntimeConfiguration (#6)
# Add global RuntimeConfiguration ## ♻️ Current situation & Problem Within the `SpeziChat` project, we discovered the need for a global runtime configuration object that holds certain testing support variables (e.g. about the debug mode). ## ⚙️ Release Notes - Add global `RuntimeConfiguration` accessible via the `TestingSupport` SPI target. ## 📚 Documentation Added proper documentation ## ✅ Testing No new test cases written ## 📝 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).
- Loading branch information
1 parent
0346857
commit 662f25d
Showing
5 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
/// Holds globally accessible runtime testing support configurations. | ||
/// | ||
/// The ``RuntimeConfig`` stores configurations of the current runtime environment for testing support. | ||
/// | ||
/// - Important: ``RuntimeConfig`` is only exposed as the [System Programming Interface (SPI)](https://blog.eidinger.info/system-programming-interfaces-spi-in-swift-explained) | ||
/// target `TestingSupport`, therefore requiring to state the SPI target upon importing the `SpeziFoundation` target via `@_spi(TestingSupport)`. | ||
/// | ||
/// ### Usage | ||
/// | ||
/// One is able to access the ``RuntimeConfig`` from the `TestingSupport` SPI target as shown below. | ||
/// | ||
/// ```swift | ||
/// // Import the entire target, including the `TestingSupport` SPI target. | ||
/// @_spi(TestingSupport) import SpeziFoundation | ||
/// | ||
/// if RuntimeConfig.testMode { /* ... */ } | ||
/// ``` | ||
/// | ||
/// As of Swift 5.8, one is able to only import the SPI target, without any other parts of the overall SPM target, | ||
/// by setting the `-experimental-spi-only-imports` Swift compiler flag and using the `@_spiOnly` notation upon target import. | ||
/// | ||
/// ```swift | ||
/// // Import only the `TestingSupport` SPI target. | ||
/// @_spiOnly import SpeziFoundation | ||
/// | ||
/// if RuntimeConfig.testMode { /* ... */ } | ||
/// ``` | ||
@_spi(TestingSupport) | ||
public struct RuntimeConfig: Sendable { | ||
public static let testMode: Bool = ProcessInfo.processInfo.arguments.contains("--testMode") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters