Skip to content

Fix Live Activity compilation and display issues for Mac Catalyst#4495

Merged
bgoncal merged 9 commits intohome-assistant:mainfrom
rwarner:fix/live-activity-macos-followup
Apr 9, 2026
Merged

Fix Live Activity compilation and display issues for Mac Catalyst#4495
bgoncal merged 9 commits intohome-assistant:mainfrom
rwarner:fix/live-activity-macos-followup

Conversation

@rwarner
Copy link
Copy Markdown
Contributor

@rwarner rwarner commented Apr 9, 2026

Summary

Follow-up fixes after #4444 merged, addressing issues found during Mac Catalyst testing:

  • Fix character in Frequent Updates footer.strings files don't interpret \uXXXX escapes at runtime; replaced with the literal character
  • Fix Mac Catalyst compilationActivityKit APIs (ActivityAttributes, Activity, ActivityUIDismissalPolicy, etc.) are marked unavailable on Mac Catalyst even though canImport(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.swift
    • LiveActivityRegistry.swift
    • HandlerLiveActivity.swift
    • LiveActivitySettingsView.swift
    • HADynamicIslandView.swift
    • HALockScreenView.swift
    • HALiveActivityConfiguration.swift
    • Widgets.swift (three HALiveActivityConfiguration() call sites)
    • Environment.swift, AppDelegate.swift, HAAPI.swift, NotificationsCommandManager.swift, SettingsItem.swift (inline guards)

Test plan

  • iOS builds and runs
  • macOS (Mac Catalyst) builds and launches
  • Live Activities settings entry does not appear on macOS (filtered by isTestFlight + #available(iOS 17.2, *))
  • Live Activities work as expected on iOS TestFlight build

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 9, 2026 14:38
rwarner and others added 8 commits April 9, 2026 10:41
.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>
@rwarner rwarner force-pushed the fix/live-activity-macos-followup branch from ca4448a to 224ffb0 Compare April 9, 2026 14:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 #else clause 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

- 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>
@bgoncal bgoncal merged commit 295a2a7 into home-assistant:main Apr 9, 2026
6 checks passed
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@b15a8ae). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants