LambdaDigamma/OneSecStudySpeziIntegrationInterface

★ 0Forks 0SwiftGitHub ↗Compare

README

SpeziOneSecIntegrationInterface

Build and Test codecov DOI

Interface for the SpeziOneSecIntegration package.

Overview

This Swift package implements the interface of the Stanford Spezi integration for the one sec app's Digital Interventions Outcome study.

Project Structure

In order to support an overall deployment target of iOS 15, this project needs to be split up into 2 separate Swift packages:

  • SpeziOneSecIntegrationInterface (this package)
    • package deployment target: iOS 15
    • defines the interface of the integration
    • the app defines a dependency on this package, and adds it to its "link binary with libraries" build phase in Xcode
    • on launch, the app calls this package's initialize function, which, if possible, will dynamically
  • SpeziOneSecIntegration
    • package deployment target: iOS 17
    • implements the interface defined in SpeziOneSecIntegrationInterface
    • the app defines a dependency on this package, but does not add it to its "link binary with libraries" build phase
    • instead, the app should add the "SpeziOneSec" target to its "target dependencies" and its "embed frameworks" build phases
    • this ensures that the package won't get linked automatically, which would crash on pre-iOS 17 devices
    • the app never directly imports this package; instead, all interactions with it go through the interface package

Usage

Use this package to interface with the SpeziOneSecIntegration package in pre-iOS 17 deployment targets. It acts as a Spezi-independent wrapper around the SpeziOneSecIntegration module (which contains the actual implementation), working around the issue that a Swift package with a deployment target Y cannot be imported into an Xcode project with a deployment target X < Y.

  1. In your AppDelegate's willFinishLaunching function: call SpeziOneSecInterface.initialize(_:launchOptions:healthExportConfig:)
    • If the device is running iOS 17 or newer, this function will dynamically load the SpeziOneSecIntegration package into the current process, and initialize and set up Spezi.
    • If the device is running an iOS version older than iOS 17, the function will simply do nothing.
  2. Apply the .spezi() view modifier to the root of your SwiftUI view hierarchy (ideally directly in your App).
  3. You now can, in SwiftUI views that have an availabilty of iOS 17+, use @Environment(SpeziOneSecModule.self) to access the SpeziOneSecIntegration package's implementation. See that package for more info.

Contributing

Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.

License

This project is licensed under the MIT License. See Licenses for more information.

Spezi Footer Spezi Footer

Contributors

LambdaDigammalukaskollmerPSchmiedmayer

Issues