Fix Live Activity compilation and display issues for Mac Catalyst#4495
Conversation
.strings files don't interpret \uXXXX escapes at runtime; use the literal › character instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ActivityKit is iOS-only. Wrap LiveActivitySettingsView.swift in #if canImport(ActivityKit) and guard the SettingsItem reference with the same check so the Mac Catalyst target compiles cleanly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without ActivityKit, the switch case body was empty which Swift doesn't allow. EmptyView() is unreachable at runtime (the item is filtered from allVisibleCases on macOS) but satisfies the compiler. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ActivityKit can be imported on Mac Catalyst but its APIs (Activity, ActivityAttributes, ActivityUIDismissalPolicy, etc.) are iOS-only. canImport() returns true on macOS/Catalyst so the guards did not exclude the unavailable APIs. os(iOS) correctly excludes the entire block from Mac Catalyst compilation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mac Catalyst reports os(iOS) as true but ActivityKit APIs are marked unavailable on it. Replace all ActivityKit-specific #if os(iOS) guards with #if os(iOS) && !targetEnvironment(macCatalyst) to exclude the code from Mac Catalyst compilation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The outer guard wrapped multiple iOS-only properties beyond just liveActivityRegistry. Restoring it with the inner ActivityKit-specific guard nested inside. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
HADynamicIslandView, HALockScreenView, and HALiveActivityConfiguration all import ActivityKit directly. Wrap each file in #if os(iOS) && !targetEnvironment(macCatalyst). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
HALiveActivityConfiguration is iOS-only; wrap all three call sites with #if os(iOS) && !targetEnvironment(macCatalyst). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ca4448a to
224ffb0
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses Mac Catalyst compilation issues found after #4444 merged. The primary fix replaces #if canImport(ActivityKit) guards with #if os(iOS) && !targetEnvironment(macCatalyst) across multiple files, since ActivityKit APIs are unavailable on Mac Catalyst despite canImport() returning true. Additionally, it fixes the display of the › character in the Live Activity settings footer by using the literal character instead of Unicode escape sequences in the .strings file.
Changes:
- Replaced compilation guards for ActivityKit-dependent code to properly exclude Mac Catalyst (9 files)
- Fixed string escaping for the
›character in frequent updates footer (2 files) - Added proper
#elseclause in SettingsItem for type safety
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| NotificationsCommandManager.swift | Updated guards for ActivityKit code and improved comment |
| HALiveActivityAttributes.swift | Updated file-level guard |
| LiveActivityRegistry.swift | Updated file-level guard |
| HandlerLiveActivity.swift | Updated file-level guard |
| Environment.swift | Updated guard for lazy registry initialization |
| HAAPI.swift | Updated guards for import and Live Activity registration |
| AppDelegate.swift | Updated guard for Live Activity reattachment |
| SettingsItem.swift | Added guard with proper #else clause |
| LiveActivitySettingsView.swift | Updated file-level guard |
| HALiveActivityConfiguration.swift | Updated file-level guard |
| HADynamicIslandView.swift | Updated file-level guard |
| HALockScreenView.swift | Updated file-level guard |
| Widgets.swift | Added guards around three Live Activity configuration instances |
| Localizable.strings | Fixed › character display |
| Strings.swift | Updated comment to reflect corrected character |
Sources/Shared/Notifications/NotificationCommands/NotificationsCommandManager.swift
Outdated
Show resolved
Hide resolved
Sources/Shared/Notifications/NotificationCommands/NotificationsCommandManager.swift
Outdated
Show resolved
Hide resolved
- Environment.swift: #if os(iOS) && !targetEnvironment → #if !targetEnvironment (already nested inside #if os(iOS)) - NotificationsCommandManager.swift: same simplification for handler registration; also add !targetEnvironment(macCatalyst) to live_update dispatch guard Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4495 +/- ##
======================================
Coverage ? 0
======================================
Files ? 0
Lines ? 0
Branches ? 0
======================================
Hits ? 0
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Follow-up fixes after #4444 merged, addressing issues found during Mac Catalyst testing:
›character in Frequent Updates footer —.stringsfiles don't interpret\uXXXXescapes at runtime; replaced with the literal›characterActivityKitAPIs (ActivityAttributes,Activity,ActivityUIDismissalPolicy, etc.) are marked unavailable on Mac Catalyst even thoughcanImport(ActivityKit)returns true there. Replaced all#if canImport(ActivityKit)and bare#if os(iOS)guards around ActivityKit code with#if os(iOS) && !targetEnvironment(macCatalyst). Files affected:HALiveActivityAttributes.swiftLiveActivityRegistry.swiftHandlerLiveActivity.swiftLiveActivitySettingsView.swiftHADynamicIslandView.swiftHALockScreenView.swiftHALiveActivityConfiguration.swiftWidgets.swift(threeHALiveActivityConfiguration()call sites)Environment.swift,AppDelegate.swift,HAAPI.swift,NotificationsCommandManager.swift,SettingsItem.swift(inline guards)Test plan
isTestFlight+#available(iOS 17.2, *))🤖 Generated with Claude Code