Repository navigation
Add visionOS support - #350
Draft
kikeenrique wants to merge 11 commits into
Draft
kikeenrique wants to merge 11 commits into
kikeenrique wants to merge 11 commits into
Conversation
…faults UIScreen (and UIWindow.screen) are unavailable on visionOS. Reads of the screen scale now go through the view's trait environment, and the places that fell back to the main screen's bounds for a host window use a platform default instead.
…ng supports swift-snapshot-testing only vends its UIKit image strategies on iOS and tvOS, so the strategies built on top of them are gated to those platforms. The AccessibilitySnapshot product still builds for visionOS, where the parser, core rendering, and previews layers remain fully available.
Xcode 27 rejects iOS deployment targets below 15.0, so the Example targets and the Tuist-built dependencies (iOSSnapshotTestCase, Paralayout, SnapshotTesting) now target iOS 15.0. The library's own minimum is unchanged, since SwiftPM only warns about it. Apps built with the iOS 27 SDK must also adopt the UIScene life cycle, so the demo app's window setup moves into a SceneDelegate.
The iOS 26 and visionOS 26 CI legs move to the xcode-27 runner (macOS 27 host, Xcode 27.0) as iOS 27 and visionOS 27, and the model-test and string-validation jobs move off the deprecated macOS 14 image. The iOS 17 and iOS 18 legs are unchanged. The build script gains iOS_27 and visionOS_27 alongside the 26 platforms, and each visionOS platform now pins its own runtime on the Apple Vision Pro simulator instead of a generic destination. The iOS 27 image ships no iPhone 17 Pro, so iOS 27 runs on iPhone 18 Pro, which shares its 402x874 @3x screen. Reference images for iOS 27.0 are recorded with Xcode 27.0 (27A266a).
Apps built with the iOS 27 SDK must adopt the scene life cycle, but the host app's life cycle changes how snapshots render: the snapshot functions host views in a UIWindow(frame:), which UIKit attaches to the app's scene only in a legacy app. In a scene-based app that window has no windowScene, so views laid out against the status bar shift and the iOS 17/18 reference images no longer match. The Example now builds both hosts from the same sources. The legacy AccessibilitySnapshotDemo (app delegate owns the window, as before) hosts SnapshotTests and UnitTests for toolchains before Xcode 27. The new AccessibilitySnapshotDemoScenes (scene delegate owns the window) hosts SnapshotTestsScenes and UnitTestsScenes for Xcode 27 and later. Both apps share the AccessibilitySnapshotDemo module name, so the tests compile unchanged against either host. CI picks the host per leg. The iOS 27 reference images were recorded with the scene-based host, so they move to the SnapshotTestsScenes folders, and testCustomContentDemo's iOS 27 reference is replaced with the CI runner's render, which differs from a local Xcode 27 render by two anti-aliased pixels.
The development requirements listed Xcode 12.5.1/14.3.1 and iOS 16.4/17.2 simulators. They now mirror the CI legs and Scripts/build.swift, explain the legacy and scene-based host apps and when to use each, and describe how to record reference images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #349.
Draft for reference alongside the discussion in #349 — happy to reshape it based on the
answers there (e.g. platform conditionals instead of replacing the
UIScreenreads, orholding for the swift-snapshot-testing strategy story).
What this does
Package.swift: bumps swift-tools-version to 5.9 and declares.visionOS(.v1).The bump required migrating the two remote dependencies off the deprecated
.package(name:url:)form; target dependencies now reference the products by packageidentity.
UIScreenusage from the visionOS-supported targets.UIView.effectiveDisplayScale(inAccessibilitySnapshotParser) reads the scale fromthe view's trait environment, and
SnapshotPlatformDefaults(inAccessibilitySnapshotCore) supplies the host-window frame that previously came fromUIScreen.main.bounds, with an explicit 1280×720 default on visionOS. This alsoremoves the deprecated
UIWindow.screenreads inSnapshotAndLegendView.#if os(iOS) || os(tvOS)—swift-snapshot-testing only vends its UIKit image strategies on those platforms. The
AccessibilitySnapshotproduct builds for visionOS but vends no strategies there yet;the parser, core rendering, and previews layers are fully available.
FBSnapshotTestCase-Accessibility(-ObjC)remain iOS-only (ios-snapshot-test-casedoes not support visionOS).
Scripts/build.swiftgains avisionOS_26platform (build-only,generic/platform=visionOS Simulator,xrsimulatorSDK) and thespmjob builds itin a matrix alongside iOS.
traitCollection.displayScalematches the previousUIScreen-derived scale, and the default host-window frame is unchanged there.Notes
ASAccessibilityEnablerneeds no changes: the visionOS simulator runtime shipsusr/lib/libAccessibility.dylibexporting the automation symbols, and CoreSimulatorsets
IPHONE_SIMULATOR_ROOTon visionOS simulators just as on iOS.UIAccessibilityStatusUtility(Smart Invert mocking) compiles for visionOS but isunreachable there while the strategies are gated; runtime validation is a follow-up.
Testing
display-scale refactor produced zero reference-image diffs.
simulator SDK.
swift testonAccessibilitySnapshotModelpasses.Follow-ups (intentionally not in this PR)
iOSSnapshotTestCasedependency split out of the example targets first).
Snapshottingstrategy story, pending upstream support inswift-snapshot-testing (open PR: Support visionOS behind compiler directives pointfreeco/swift-snapshot-testing#1116; alternatively
a local base-strategy implementation). Once that lands, the
#if os(iOS) || os(tvOS)gates here can widen to include visionOS.