Skip to content

Commit

Permalink
Fix some platform support, swiftlint, SPI, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Sep 30, 2024
1 parent b1c6844 commit dced38b
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 56 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ jobs:
name: Build and Test Swift Package iOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
resultBundle: SpeziNotifications-iOS.xcresult
artifactname: SpeziNotifications-iOS.xcresult
packagewatchos:
name: Build and Test Swift Package watchOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
destination: 'platform=watchOS Simulator,name=Apple Watch Series 10 (46mm)'
resultBundle: SpeziNotifications-watchOS.xcresult
Expand All @@ -37,6 +39,7 @@ jobs:
name: Build and Test Swift Package visionOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
destination: 'platform=visionOS Simulator,name=Apple Vision Pro'
resultBundle: SpeziNotifications-visionOS.xcresult
Expand All @@ -45,6 +48,7 @@ jobs:
name: Build and Test Swift Package tvOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
resultBundle: SpeziNotifications-tvOS.xcresult
destination: 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)'
Expand All @@ -53,6 +57,7 @@ jobs:
name: Build and Test Swift Package macOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziNotifications-Package
resultBundle: SpeziNotifications-macOS.xcresult
destination: 'platform=macOS,arch=arm64'
Expand All @@ -61,6 +66,7 @@ jobs:
name: Build and Test iOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
resultBundle: TestApp-iOS.xcresult
Expand Down
2 changes: 2 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ builder:
- platform: ios
documentation_targets:
- SpeziNotifications
- XCTSpeziNotifications
- XCTSpeziNotificationsUI
2 changes: 2 additions & 0 deletions Sources/SpeziNotifications/Misc/BackgroundFetchResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
// SPDX-License-Identifier: MIT
//

#if os(iOS) || os(visionOS) || os(tvOS) || os(watchOS)
// BackgroundFetchResult type-alias is currently defined in Spezi. Once Spezi removes it and makes a breaking change, we can move it to this package.
@_exported import typealias Spezi.BackgroundFetchResult
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extension XCUIApplication {

/// Confirm the notification authorization dialog.
/// - Parameter action: The action to confirm the alert with.
@available(tvOS, unavailable)
public func confirmNotificationAuthorization(action: NotificationAuthorizationAction = .allow) {
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ struct NotificationRequestLabel: View {
NotificationRequestView(request)
} label: {
VStack(alignment: .leading) {
#if os(tvOS)
Text("Notification", bundle: .module)
#else
Text(request.content.title)
.bold()
#endif
if let trigger = request.trigger,
let nextDate = trigger.nextDate() {
NotificationTriggerLabel(nextDate)
Expand Down
21 changes: 14 additions & 7 deletions Sources/XCTSpeziNotificationsUI/NotificationRequestView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,32 @@ public struct NotificationRequestView: View {

public var body: some View {
List {
content

delivery

trigger

Section {
LabeledContent {
Text(request.identifier)
} label: {
Text("Identifier", bundle: .module)
}
.accessibilityElement(children: .combine)
.accessibilityElement(children: .combine)
}

#if !os(tvOS)
content
#endif

delivery

trigger
}
#if !os(tvOS)
.navigationTitle(request.content.title)
#if !os(macOS)
.navigationBarTitleDisplayMode(.inline)
#endif
#endif
}

@available(tvOS, unavailable)
@ViewBuilder private var content: some View {
Section { // swiftlint:disable:this closure_body_length
LabeledContent {
Expand Down Expand Up @@ -90,12 +95,14 @@ public struct NotificationRequestView: View {

@ViewBuilder private var delivery: some View {
Section {
#if !os(tvOS)
LabeledContent {
Text(request.content.sound != nil ? "Yes" : "No", bundle: .module)
} label: {
Text("Sound", bundle: .module)
}
.accessibilityElement(children: .combine)
#endif

LabeledContent {
Text(request.content.interruptionLevel.description)
Expand Down
7 changes: 6 additions & 1 deletion Sources/XCTSpeziNotificationsUI/NotificationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ public struct NotificationsView: View {
await queryAuthorization()
authorizationAction()
} label: {
Label("Request Notification Authorization", systemImage: "alarm.waves.left.and.right.fill")
Label {
Text("Request Notification Authorization", bundle: .module)
} icon: {
Image(systemName: "alarm.waves.left.and.right.fill")
.accessibilityHidden(true)
}
}
}
}
Expand Down
56 changes: 9 additions & 47 deletions Sources/XCTSpeziNotificationsUI/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@
}
}
},
"active" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "active"
}
}
}
},
"Body" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -62,17 +51,6 @@
}
}
},
"critical" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "critical"
}
}
}
},
"Delivery" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -173,13 +151,12 @@
}
}
},
"passive" : {
"extractionState" : "stale",
"Notification" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "passive"
"value" : "Notification"
}
}
}
Expand Down Expand Up @@ -215,45 +192,41 @@
}
},
"Request Notification Authorization" : {

},
"Sound" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sound"
"value" : "Request Notification Authorization"
}
}
}
},
"Subtitle" : {
"Sound" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Subtitle"
"value" : "Sound"
}
}
}
},
"Thread" : {
"Subtitle" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Thread"
"value" : "Subtitle"
}
}
}
},
"timeSensitive" : {
"extractionState" : "stale",
"Thread" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "timeSensitive"
"value" : "Thread"
}
}
}
Expand Down Expand Up @@ -298,17 +271,6 @@
}
}
},
"unknown(%llu)" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "unknown(%llu)"
}
}
}
},
"Yes" : {
"localizations" : {
"en" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension UNNotificationTrigger {
} else if self is UNPushNotificationTrigger {
LocalizedStringResource("Push", bundle: .atURL(from: .module))
} else {
#if !os(visionOS) && !os(macOS)
#if !os(visionOS) && !os(macOS) && !os(tvOS)
if self is UNLocationNotificationTrigger {
LocalizedStringResource("Location", bundle: .atURL(from: .module))
} else {
Expand Down

0 comments on commit dced38b

Please sign in to comment.