Skip to content

Make the package build for watchOS - #8

Open
Jeehut wants to merge 3 commits into
mainfrom
wip/fix-watchos-build
Open

Jeehut wants to merge 3 commits into
mainfrom
wip/fix-watchos-build

Conversation

@Jeehut

@Jeehut Jeehut commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Overview

watchOS 9 is a declared platform in Package.swift, but the package did not compile for it: 52 distinct errors in 8 files. Fixing those uncovered more in LimitedTextField, SideTabView and two previews. This PR makes the package build for watchOS. Helpers that cannot work there, or would be awkward on a watch, are compiled out, and the colors with a natural watchOS counterpart are mapped instead of removed. The other platforms are unaffected.

What is available on watchOS now

Symbol watchOS Why
Color.label, secondaryLabel .primary, .secondary UIKit on watchOS has no semantic label colors; SwiftUI's hierarchical colors are the watch equivalent
Color.systemBlue, systemGreen, systemIndigo, systemOrange, systemPink, systemPurple, systemRed, systemTeal, systemYellow, systemGray SwiftUI's .blue, .green, … UIKit on watchOS has no system* colors; SwiftUI's standard colors use the watch's system palette
HPicker, VPicker watchOS 10+ (@available(watchOS 10.0, *)) They use .thinMaterial / .regularMaterial, which watchOS only has from version 10
UIImage.heicData(compressionQuality:) available Only needed an import ImageIO

Unavailable on watchOS (compiled out with #if !os(watchOS))

Symbol Why
Color.tertiaryLabel, quaternaryLabel, separator, opaqueSeparator, link No UIKit color on watchOS and no SwiftUI equivalent
Color.systemFill … quaternarySystemFill, placeholderText, systemBackground … tertiarySystemGroupedBackground, systemGray2 … systemGray6 Same reason (these were already excluded on tvOS for the same reason)
UIImage.resized(maxWidth:maxHeight:) watchOS has neither UIGraphicsImageRenderer nor UIScreen
View.onAppBecomeActive(_:), onAppResignActive(_:) watchOS apps have no UIApplication; their lifecycle notifications come from WKApplication
SideTabView Uses GroupBox, which watchOS does not have, and a side rail of tabs does not fit a watch screen

The #Previews of AsyncButton, DisclosureSection, HorizontalLabeledContentStyle, HPicker and VPicker skip watchOS, since they use GroupBox, DisclosureGroup or watchOS 10 API. LimitedTextField keeps its default text field style on watchOS, as it already did on tvOS, because .roundedBorder is unavailable there.

How this was verified

xcodebuild -scheme HandySwiftUI -destination 'generic/platform=watchOS' build (derived data in a scratch folder), on main and on this branch:

main:
** BUILD FAILED **
  33 errors  Extensions/ColorExt.swift   ('label' is unavailable in watchOS, 'systemBlue' is unavailable in watchOS, …)
  26 errors  Styles/HorizontalLabeledContentStyle.swift   ('GroupBox' is unavailable in watchOS)
  26 errors  Types/Views/AsyncButton.swift   ('GroupBox' is unavailable in watchOS)
  22 errors  Types/Views/DisclosureSection.swift   ('DisclosureGroup' is unavailable in watchOS)
   6 errors  Extensions/ImageExt.swift   ('UIGraphicsImageRenderer' is unavailable in watchOS, cannot find 'CGImageDestinationCreateWithData' in scope, …)
   4 errors  Modifiers/ViewExt.swift   ('UIApplication' is unavailable in watchOS, …)
   2 errors  Types/Views/HPicker.swift   ('thinMaterial' is only available in watchOS 10.0 or newer, …)
   1 error   Types/Views/VPicker.swift   ('thinMaterial' is only available in watchOS 10.0 or newer)
  (52 distinct messages)

this branch:
** BUILD SUCCEEDED ** [17.662 sec]

The remaining watchOS warnings are the same ones every platform already shows on main (HandyRegex deprecation, the #warning TODOs, the unused throwing task in AsyncButton).

swift build (macOS) and xcodebuild for generic iOS, tvOS and visionOS produced the same deduplicated diagnostics (file + message) as on main, with no new warnings or errors.

CI

A new matrix job build-platforms runs xcodebuild -scheme HandySwiftUI -destination 'generic/platform=<platform>' CODE_SIGNING_ALLOWED=NO build for iOS, tvOS, visionOS and watchOS, so a platform that stops compiling fails the PR. Generic destinations need the platform SDKs but no simulator runtimes, and the macos-26 runner has all four SDKs: on this PR all four jobs passed (1m25s–1m50s) without -skipMacroValidation. The macOS job uses --build-system swiftbuild like #6 and #7. The new job is listed before test-macos, so this workflow merges cleanly after #6 and #7. That was checked by merging main ← #6 ← #7 ← #8 locally: no conflicts, all five platforms build, and swift test --build-system swiftbuild passes 35 tests.

watchOS is a declared platform, but the package failed to compile for
it with 52 distinct errors. UIKit on watchOS has no semantic colors,
no UIApplication, UIScreen or UIGraphicsImageRenderer, and SwiftUI
there has no GroupBox, DisclosureGroup or rounded text field style.

The label and standard colors now map to SwiftUI's own colors on
watchOS, which follow the watch's system palette. Helpers without a
sensible watchOS counterpart are compiled out: the background, fill,
separator, link, tertiary/quaternary label and gray 2-6 colors,
UIImage.resized, onAppBecomeActive/onAppResignActive and SideTabView.
HPicker and VPicker need the materials of watchOS 10 and are marked
accordingly. Previews that use unavailable views skip watchOS, and
importing ImageIO makes heicData(compressionQuality:) work there.
watchOS was a declared platform that did not compile, and nothing
noticed because CI only built for macOS. A matrix job now builds the
package for iOS, tvOS, visionOS and watchOS with generic destinations,
which need the SDKs but no simulator runtimes. The macOS job uses the
swiftbuild build system like on the other open branches, so the
workflow changes merge cleanly.
With the new job appended right after the swift test line, git could
not merge this workflow with the swiftbuild change of the other open
branches. Placed before test-macos, both changes merge cleanly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant