Skip to content

Commit

Permalink
Introduce SpeziNotifications (#1)
Browse files Browse the repository at this point in the history
# Introduce SpeziNotifications

## ♻️ Current situation & Problem
This PR marks the first release of the SpeziNotifications package. It
introduces the `Notifications` Module and introduces two new actions:
`notificationSettings` to retrieve the current notification settings
(e.g., authorization status) and `requestNotificationAuthorization`. All
notification related actions are accessible through the `@Application`
property wrapper inside Spezi Modules and the `@Environment` property
wrapper inside SwiftUI Views. The `registerRemoteNotifications` and
`unregisterRemoteNotifications` actions are now also available via the
`@Environment` property wrapper.
Some infrastructure is still exported through Spezi (see
StanfordSpezi/Spezi#117).

## ⚙️ Release Notes 
Each target exposes a structured DocC documentation catalog and
documents all public interfaces.


## 📚 Documentation
* New `@Application(\.notificationSettings)` and
`@Environment(\.notificationSettings)` action to retrieve current
notification settings like the authorization status.
* New `@Application(\.requestNotificationAuthorization)` and
`@Environment(\. requestNotificationAuthorization)` action to easily
request notification authorization.
* New `Notifications` module that makes it easier to interact with
notification related actions in Spezi application and ensures to silence
concurrency warnings.
* New `XCTSpeziNotifications` target to easily handle notification
authorization alerts in UI tests.
* New `XCTSpeziNotificationsUI` target that can be used in UI test
application to visualize pending notification requests.


## ✅ Testing
Added extensive unit and UI testing for all components.

## 📝 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
Supereg authored Oct 28, 2024
1 parent e51b63d commit 38fcb2b
Show file tree
Hide file tree
Showing 64 changed files with 2,623 additions and 681 deletions.
102 changes: 35 additions & 67 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the SpeziNotifications open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand All @@ -14,110 +14,78 @@ on:
jobs:
reuse_action:
name: REUSE Compliance Check
uses: StanfordBDHG/.github/.github/workflows/reuse.yml@v2
uses: StanfordSpezi/.github/.github/workflows/reuse.yml@v2
swiftlint:
name: SwiftLint
uses: StanfordBDHG/.github/.github/workflows/swiftlint.yml@v2
uses: StanfordSpezi/.github/.github/workflows/swiftlint.yml@v2
packageios:
name: Build and Test Swift Package iOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
resultBundle: TemplatePackage-iOS.xcresult
artifactname: TemplatePackage-iOS.xcresult
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
resultBundle: SpeziNotifications-iOS.xcresult
artifactname: SpeziNotifications-iOS.xcresult
packagewatchos:
name: Build and Test Swift Package watchOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
destination: 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)'
resultBundle: TemplatePackage-watchOS.xcresult
artifactname: TemplatePackage-watchOS.xcresult
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
destination: 'platform=watchOS Simulator,name=Apple Watch Series 10 (46mm)'
resultBundle: SpeziNotifications-watchOS.xcresult
artifactname: SpeziNotifications-watchOS.xcresult
packagevisionos:
name: Build and Test Swift Package visionOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
destination: 'platform=visionOS Simulator,name=Apple Vision Pro'
resultBundle: TemplatePackage-visionOS.xcresult
artifactname: TemplatePackage-visionOS.xcresult
resultBundle: SpeziNotifications-visionOS.xcresult
artifactname: SpeziNotifications-visionOS.xcresult
packagetvos:
name: Build and Test Swift Package tvOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
resultBundle: TemplatePackage-tvOS.xcresult
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
resultBundle: SpeziNotifications-tvOS.xcresult
destination: 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)'
artifactname: TemplatePackage-tvOS.xcresult
artifactname: SpeziNotifications-tvOS.xcresult
packagemacos:
name: Build and Test Swift Package macOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
scheme: TemplatePackage
resultBundle: TemplatePackage-macOS.xcresult
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
resultBundle: SpeziNotifications-macOS.xcresult
destination: 'platform=macOS,arch=arm64'
artifactname: TemplatePackage-macOS.xcresult
artifactname: SpeziNotifications-macOS.xcresult
ios:
name: Build and Test iOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
resultBundle: TestApp-iOS.xcresult
artifactname: TestApp-iOS.xcresult
ipados:
name: Build and Test iPadOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
path: 'Tests/UITests'
scheme: TestApp
destination: 'platform=iOS Simulator,name=iPad Air (5th generation)'
resultBundle: TestApp-iPadOS.xcresult
artifactname: TestApp-iPadOS.xcresult
watchos:
name: Build and Test watchOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestAppWatchApp
destination: 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)'
resultBundle: TestApp-watchOS.xcresult
artifactname: TestApp-watchOS.xcresult
visionos:
name: Build and Test visionOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
destination: 'platform=visionOS Simulator,name=Apple Vision Pro'
resultBundle: TestApp-visionOS.xcresult
artifactname: TestApp-visionOS.xcresult
tvos:
name: Build and Test tvOS
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
path: 'Tests/UITests'
scheme: TestApp
destination: 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)'
resultBundle: TestApp-tvOS.xcresult
artifactname: TestApp-tvOS.xcresult
codeql:
name: CodeQL
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
codeql: true
test: false
scheme: TemplatePackage
permissions:
security-events: write
actions: read
uploadcoveragereport:
name: Upload Coverage Report
needs: [packageios, packagewatchos, packagevisionos, packagetvos, packagemacos, ios, ipados, watchos, visionos, tvos]
uses: StanfordBDHG/.github/.github/workflows/create-and-upload-coverage-report.yml@v2
needs: [packageios, packagewatchos, packagevisionos, packagetvos, packagemacos, ios, visionos]
uses: StanfordSpezi/.github/.github/workflows/create-and-upload-coverage-report.yml@v2
with:
coveragereports: TemplatePackage-iOS.xcresult TemplatePackage-watchOS.xcresult TemplatePackage-visionOS.xcresult TemplatePackage-tvOS.xcresult TemplatePackage-macOS.xcresult TestApp-iOS.xcresult TestApp-iPadOS.xcresult TestApp-watchOS.xcresult TestApp-visionOS.xcresult TestApp-tvOS.xcresult
coveragereports: SpeziNotifications-iOS.xcresult SpeziNotifications-watchOS.xcresult SpeziNotifications-visionOS.xcresult SpeziNotifications-tvOS.xcresult SpeziNotifications-macOS.xcresult TestApp-iOS.xcresult TestApp-visionOS.xcresult
secrets:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the SpeziNotifications open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the SpeziNotifications open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the SpeziNotifications open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down
6 changes: 4 additions & 2 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the SpeziNotifications open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand All @@ -11,4 +11,6 @@ builder:
configs:
- platform: ios
documentation_targets:
- TemplatePackage
- SpeziNotifications
- XCTSpeziNotifications
- XCTSpeziNotificationsUI
9 changes: 1 addition & 8 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the SpeziNotifications open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down Expand Up @@ -367,13 +367,6 @@ only_rules:
# The variable should be placed on the left, the constant on the right of a comparison operator.
- yoda_condition

attributes:
attributes_with_arguments_always_on_line_above: false

deployment_target: # Availability checks or attributes shouldn’t be using older versions that are satisfied by the deployment target.
iOSApplicationExtension_deployment_target: 16.0
iOS_deployment_target: 16.0

excluded: # paths to ignore during linting. Takes precedence over `included`.
- .build
- .swiftpm
Expand Down
14 changes: 7 additions & 7 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the SpeziNotifications open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
# SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#
Expand All @@ -12,9 +12,9 @@ authors:
- family-names: "Schmiedmayer"
given-names: "Paul"
orcid: "https://orcid.org/0000-0002-8607-9148"
- family-names: "Ravi"
given-names: "Vishnu"
orcid: "https://orcid.org/0000-0003-0359-1275"
title: "TemplatePackage"
- family-names: "Bauer"
given-names: "Andreas"
orcid: "https://orcid.org/0000-0002-1680-237X"
title: "SpeziNotifications"
doi: 10.5281/zenodo.7538165
url: "https://github.com/StanfordBDHG/SwiftPackageTemplate"
url: "https://github.com/StanfordSpezi/SpeziNotifications"
8 changes: 4 additions & 4 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!--
#
# This source file is part of the TemplatePackage open source project
# This source file is part of the SpeziNotifications open source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
# SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#
-->

TemplatePackage contributors
SpeziNotifications contributors
====================

* [Paul Schmiedmayer](https://github.com/PSchmiedmayer)
* [Vishnu Ravi](https://github.com/vishnuravi)
* [Andreas Bauer](https://github.com/Supereg)
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
MIT License

Copyright (c) 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
Copyright (c) 2024 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.
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.
4 changes: 2 additions & 2 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
MIT License

Copyright (c) 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
Copyright (c) 2024 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.
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.
70 changes: 59 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// swift-tools-version:5.9
// swift-tools-version:6.0

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

import class Foundation.ProcessInfo
import PackageDescription


let package = Package(
name: "TemplatePackage",
name: "SpeziNotifications",
defaultLocalization: "en",
platforms: [
.iOS(.v17),
.watchOS(.v10),
Expand All @@ -21,17 +23,63 @@ let package = Package(
.macOS(.v14)
],
products: [
.library(name: "TemplatePackage", targets: ["TemplatePackage"])
.library(name: "SpeziNotifications", targets: ["SpeziNotifications"]),
.library(name: "XCTSpeziNotifications", targets: ["XCTSpeziNotifications"]),
.library(name: "XCTSpeziNotificationsUI", targets: ["XCTSpeziNotificationsUI"])
],
dependencies: [
.package(url: "https://github.com/StanfordSpezi/Spezi.git", branch: "feature/application-for-swiftui"),
.package(url: "https://github.com/StanfordSpezi/SpeziViews.git", branch: "feature/additional-infrastructure")
] + swiftLintPackage(),
targets: [
.target(
name: "TemplatePackage"
name: "SpeziNotifications",
dependencies: [
.product(name: "Spezi", package: "Spezi")
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "XCTSpeziNotifications",
dependencies: [
.target(name: "SpeziNotifications")
],
plugins: [] + swiftLintPlugin()
),
.target(
name: "XCTSpeziNotificationsUI",
dependencies: [
.target(name: "SpeziNotifications"),
.product(name: "SpeziViews", package: "SpeziViews")
],
plugins: [] + swiftLintPlugin()
),
.testTarget(
name: "TemplatePackageTests",
name: "SpeziNotificationsTests",
dependencies: [
.target(name: "TemplatePackage")
]
.target(name: "SpeziNotifications"),
.product(name: "Spezi", package: "Spezi"),
.product(name: "XCTSpezi", package: "Spezi")
],
plugins: [] + swiftLintPlugin()
)
]
)


func swiftLintPlugin() -> [Target.PluginUsage] {
// Fully quit Xcode and open again with `open --env SPEZI_DEVELOPMENT_SWIFTLINT /Applications/Xcode.app`
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint")]
} else {
[]
}
}

func swiftLintPackage() -> [PackageDescription.Package.Dependency] {
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.package(url: "https://github.com/realm/SwiftLint.git", from: "0.55.1")]
} else {
[]
}
}
Loading

0 comments on commit 38fcb2b

Please sign in to comment.