Skip to content
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
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# This source file is part of the OneSecStanfordStudy open-source project
#
# SPDX-FileCopyrightText: 2026 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#

name: CI

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
actions: read
contents: read
issues: write
pull-requests: write

jobs:
swift-package-ci:
name: Swift Package CI
uses: SchmiedmayerLab/.github/.github/workflows/swift-package-ci.yml@v0.2
secrets: inherit

all-tests-pass:
name: All tests pass
if: always()
needs: swift-package-ci
runs-on: ubuntu-latest
steps:
- name: Verify CI results
run: |
echo "swift-package-ci = ${{ needs.swift-package-ci.result }}"
if [ "${{ needs.swift-package-ci.result }}" != "success" ]; then
echo "::error::Swift Package CI did not pass."
exit 1
fi
echo "All required checks passed."
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.DS_Store

# Swift Package Manager
/.build/
.build/
**/.build/
/.swiftpm/
.swiftpm/
**/.swiftpm/
/Package.resolved
Package.resolved

# Xcode
DerivedData/
**/DerivedData/
.derivedData/
**/.derivedData/
xcuserdata/
**/xcuserdata/
*.xcuserstate
*.xcscmblueprint

# SwiftPM/Xcode editor output
.vscode/
14 changes: 14 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# This source file is part of the OneSecStanfordStudy open-source project
#
# SPDX-FileCopyrightText: 2026 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#

version: 1
builder:
configs:
- platform: ios
documentation_targets:
- OneSecStanfordStudy
20 changes: 20 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# This source file is part of the OneSecStanfordStudy open-source project
#
# SPDX-FileCopyrightText: 2026 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#

excluded:
- .build
- .swiftpm
- .derivedData
- Tests/UITests/.derivedData

disabled_rules:
- blanket_disable_command

line_length:
warning: 150
error: 150
22 changes: 22 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--

This source file is part of the OneSecStanfordStudy open-source project

SPDX-FileCopyrightText: 2026 Stanford University and the project authors (see CONTRIBUTORS.md)

SPDX-License-Identifier: MIT

-->

OneSecStanfordStudy contributors
====================

* [Lukas Kollmer](https://github.com/lukaskollmer)
* [Lennart Fischer](https://github.com/LambdaDigamma)
* [Paul Schmiedmayer](https://github.com/PSchmiedmayer)


Attributions
------------

This package is based on the original [implementation repository](https://github.com/StanfordBDHG/OneSecStudySpeziIntegration) and [interface repository](https://github.com/StanfordBDHG/OneSecStudySpeziIntegrationInterface), which were published under the MIT License.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2026 Stanford University and the project authors (see CONTRIBUTORS.md)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 9 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2026 Stanford University and the project authors (see CONTRIBUTORS.md)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 changes: 50 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// swift-tools-version:6.2

//
// This source file is part of the OneSecStanfordStudy open-source project
//
// SPDX-FileCopyrightText: 2026 Stanford University and the project authors (see CONTRIBUTORS.md)
//
// SPDX-License-Identifier: MIT
//

import PackageDescription

let swiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("InternalImportsByDefault")
]

let package = Package(
name: "OneSecStanfordStudy",
platforms: [
.iOS(.v15)
],
products: [
.library(name: "OneSecStanfordStudy", targets: ["OneSecStanfordStudy"])
],
dependencies: [
.package(url: "https://github.com/SchmiedmayerLab/Spezi.git", revision: "d55dd3a84fc21fc4f6153cb90f08fbb381b6ec0d", traits: [])
],
targets: [
.target(
name: "OneSecStanfordStudy",
dependencies: [
.product(name: "Spezi", package: "Spezi"),
.product(name: "SpeziFoundation", package: "Spezi"),
.product(name: "SpeziHealthKit", package: "Spezi"),
.product(name: "SpeziHealthKitBulkExport", package: "Spezi"),
.product(name: "HealthKitOnFHIR", package: "Spezi")
],
swiftSettings: swiftSettings
),
.testTarget(
name: "OneSecStanfordStudyTests",
dependencies: [
.target(name: "OneSecStanfordStudy")
],
swiftSettings: swiftSettings
)
],
swiftLanguageModes: [.v6]
)
123 changes: 123 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<!--

This source file is part of the OneSecStanfordStudy open-source project

SPDX-FileCopyrightText: 2026 Stanford University and the project authors (see CONTRIBUTORS.md)

SPDX-License-Identifier: MIT

-->

# OneSecStanfordStudy

Stanford study integration module for the one sec app's Digital Interventions Outcome study.


## Overview

This package combines the original interface and implementation packages into one package that depends on the Spezi monorepo.

The old two-package setup worked around a deployment-target mismatch by dynamically loading the iOS 18 implementation from a separate framework while exposing an iOS 15 interface package.
The new single-repo version no longer needs that workaround: apps can depend on this single package and link the implementation directly.


## Installation

Add this package to your app and select the `OneSecStanfordStudy` product. The package can be added to app targets that support iOS 15 or newer. The study integration is active on iOS 18 and newer; on older iOS versions, initialization and the root view modifier are no-ops.

This setup temporarily depends on the Spezi monorepo feature branch that adds the monorepo-backed deployment target support:

```swift
.package(url: "https://github.com/SchmiedmayerLab/Spezi.git", branch: "oldiOSVersion", traits: [])
```

After the Spezi changes are merged and tagged, replace the branch dependency with the tagged `0.x` release range:

```swift
.package(url: "https://github.com/SchmiedmayerLab/Spezi.git", "0.1.0"..<"0.2.0", traits: [])
```

Then add the product dependency to the target that needs it:

```swift
.target(
name: "MyApp",
dependencies: [
.product(name: "OneSecStanfordStudy", package: "OneSecStanfordStudy")
]
)
```


## Usage

Call `initializeOneSecStanfordStudy(_:launchOptions:healthExportConfig:)` from your app delegate's `application(_:willFinishLaunchingWithOptions:)` method:

```swift
import OneSecStanfordStudy
import UIKit

final class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
initializeOneSecStanfordStudy(
application,
launchOptions: launchOptions,
healthExportConfig: HealthExportConfiguration(
destination: healthExportDirectory,
sampleTypes: sampleTypes,
timeRange: timeRange,
didStartExport: { files in
// Upload or process the generated files.
},
didEndExport: {
// Handle completion.
}
)
)
return true
}
}
```

Apply `.oneSecStanfordStudy()` to the root of your SwiftUI hierarchy:

```swift
WindowGroup {
ContentView()
.oneSecStanfordStudy()
}
```

The runtime is configured directly and `OneSecStanfordStudyModule` is available through SwiftUI environment injection:

```swift
@Environment(OneSecStanfordStudyModule.self) private var oneSec
```


## Testing

The package includes unit tests in `Tests/OneSecStanfordStudyTests` and a consolidated iOS UI test app in `Tests/UITests`.

Run the UI test app with the `TestApp` scheme in `Tests/UITests/UITests.xcodeproj`. The test app has an iOS 15 deployment target. On iOS 15 and iOS 16, the wrapper launch test validates that initialization and `.oneSecStanfordStudy()` are no-ops. On iOS 18 and newer, the same app validates the active integration and the web view alert/confirm hooks.


## Contributing

Contributions to this project are welcome. Please make sure to read the [contribution guide](https://github.com/SchmiedmayerLab/Spezi/blob/main/Sources/Spezi/Spezi.docc/Contributing%20Guide.md) and the [Contributor Covenant Code of Conduct](https://github.com/SchmiedmayerLab/.github/blob/main/CODE_OF_CONDUCT.md) first.


## License

This project is licensed under the MIT License. See [Licenses](LICENSES) for more information.


## Contributors

The local [CONTRIBUTORS.md](CONTRIBUTORS.md) file records contributors from the original upstream repositories.

![Stanford and Stanford Medicine logos](https://raw.githubusercontent.com/SchmiedmayerLab/.github/main/assets/stanford-footer-light.png#gh-light-mode-only)
![Stanford and Stanford Medicine logos](https://raw.githubusercontent.com/SchmiedmayerLab/.github/main/assets/stanford-footer-dark.png#gh-dark-mode-only)
12 changes: 12 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version = 1

[[annotations]]
path = [
".gitignore",
"Tests/UITests/TestApp/Assets.xcassets/**",
"Tests/UITests/TestApp/TestApp.entitlements",
"Tests/UITests/TestApp.xctestplan",
"Tests/UITests/UITests.xcodeproj/**"
]
SPDX-FileCopyrightText = "2026 Stanford University and the project authors (see CONTRIBUTORS.md)"
SPDX-License-Identifier = "MIT"
Loading
Loading