Add tvOS UITest runner support#53
Conversation
The DeviceKit XCUITest runner now builds for tvOS, so the automation stack can drive the tvOS Simulator. - Add a `devicekit-tvos` scheme and tvOS target to the Xcode project, plus a `scripts/patch-tvos-runner.sh` helper and Makefile targets that build and patch the tvOS runner. - On tvOS, register a `device.io.button` handler that maps button names to `XCUIRemote.Button` presses (up, down, left, right, select, menu, home, playPause). tvOS navigates by focus, not touch. - Keep the touch, keyboard, and orientation handlers iOS-only in the JSON-RPC dispatcher, behind `#if os(iOS)`. - Read the screen size from `UIScreen.main.bounds` on tvOS, since there is no SpringBoard to query. - Guard the remaining iOS-only handlers and helpers with `#if os(iOS)` so the shared sources still compile for both platforms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (9)
📒 Files selected for processing (19)
👮 Files not reviewed due to content moderation or server errors (19)
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Makefile`:
- Line 137: The tvOS simulator lookup in the Makefile can pick the wrong booted
device because the current selector takes the first booted UDID across all
runtimes. Update the `tvos-sim-install` booted-device selection logic to filter
the `xcrun simctl list devices booted -j` results by tvOS runtime before
choosing the UDID, keeping the change localized to the `BOOTED` assignment used
by that target.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9224b49b-8a90-4ecc-9ece-a11fcbe7ccc0
📒 Files selected for processing (20)
DeviceKitTests/JSONRPC/Handlers/DeviceInfo.swiftDeviceKitTests/JSONRPC/Handlers/IOButton.swiftDeviceKitTests/JSONRPC/Handlers/IOGesture.swiftDeviceKitTests/JSONRPC/Handlers/IOKeys.swiftDeviceKitTests/JSONRPC/Handlers/IOLongpress.swiftDeviceKitTests/JSONRPC/Handlers/IOOrientationGet.swiftDeviceKitTests/JSONRPC/Handlers/IOOrientationSet.swiftDeviceKitTests/JSONRPC/Handlers/IOSwipe.swiftDeviceKitTests/JSONRPC/Handlers/IOTap.swiftDeviceKitTests/JSONRPC/Handlers/IOText.swiftDeviceKitTests/JSONRPC/JSONRPCDispatcher.swiftDeviceKitTests/XCTest/EventRecord.swiftDeviceKitTests/XCTest/OrientationGeometry.swiftDeviceKitTests/XCTest/PointerEventPath.swiftDeviceKitTests/XCTest/RunnerDaemonProxy.swiftDeviceKitTests/XCTest/SystemPermissionManager.swiftMakefiledevicekit-ios.xcodeproj/project.pbxprojdevicekit-ios.xcodeproj/xcshareddata/xcschemes/devicekit-tvos.xcschemescripts/patch-tvos-runner.sh
|
|
||
| # Build and install tvOS runner on the booted tvOS simulator | ||
| tvos-sim-install: | ||
| @BOOTED=$$(xcrun simctl list devices booted -j | jq -r '[.devices[][] | select(.state=="Booted")] | first | .udid'); \ |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Inspect the structure/keys of `simctl list devices -j` to confirm tvOS runtime key naming.
xcrun simctl list devices -j 2>/dev/null | jq -r '.devices | keys' || echo "simctl unavailable in this environment"Repository: mobile-next/devicekit-ios
Length of output: 2002
🌐 Web query:
xcrun simctl list devices -j tvOS runtime key format CoreSimulator.SimRuntime.tvOS JSON
💡 Result:
The command xcrun simctl list devices -j outputs a JSON object where the primary key for grouping simulators is the runtime identifier (e.g., com.apple.CoreSimulator.SimRuntime.tvOS-XX-X) [1][2]. When you run xcrun simctl list devices -j, the resulting JSON structure is organized as follows: 1. Root Object: Contains a key named devices [1][2]. 2. Devices Dictionary: The devices object contains keys representing each installed simulator runtime (such as com.apple.CoreSimulator.SimRuntime.tvOS-18-2) [2][3]. 3. Simulator Array: Each runtime key maps to an array of objects, where each object represents an individual simulator device and includes fields such as name, udid, state, and isAvailable [2][4]. To parse the runtime key format—which follows the pattern com.apple.CoreSimulator.SimRuntime.[Platform]-[Version]—you can programmatically split the string or use regex [2][5]. For example, extracting the platform and version from com.apple.CoreSimulator.SimRuntime.tvOS-13-4 involves splitting by the dash character after the prefix [5]. Note that: - You can filter the JSON output efficiently using tools like jq to isolate specific platforms (e.g., jq '.devices | to_entries | map(select(.key | startswith("tvOS"))) | from_entries') [1]. - The isAvailable boolean field is critical for identifying whether a simulator is ready for use, as the list may include unavailable runtimes [2][4]. - In some scenarios, especially when multiple Xcode versions are involved, runtime identifiers might be duplicated or squashed in the JSON output, which can lead to unexpected behavior in automated scripts [6].
Citations:
- 1: https://www.iosdev.recipes/simctl/listing-devices
- 2: https://stackoverflow.com/questions/58806843/how-to-get-list-of-available-ios-simulators
- 3: https://chromium.googlesource.com/chromium/src/+/HEAD/ios/build/bots/scripts/iossim_util_test.py
- 4: bug: react-native run-ios cannot find any simulator (after installing Xcode 11 beta) react-native-community/cli#658
- 5: https://github.com/expo/expo-cli/blob/54997b9b/packages/xdl/src/SimControl.ts
- 6: https://gist.github.com/erikkerber/630e00c1afebd3ef6881a60a22e2e15b
tvos-sim-install can select the wrong booted simulator. xcrun simctl list devices booted -j still returns booted devices across all runtimes, so first can resolve to an iOS simulator when one is booted too. Filter for tvOS runtimes before choosing the UDID.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Makefile` at line 137, The tvOS simulator lookup in the Makefile can pick the
wrong booted device because the current selector takes the first booted UDID
across all runtimes. Update the `tvos-sim-install` booted-device selection logic
to filter the `xcrun simctl list devices booted -j` results by tvOS runtime
before choosing the UDID, keeping the change localized to the `BOOTED`
assignment used by that target.
Add a compiled brandassets catalog (imagestack/imagestacklayer) for the tvOS UI test runner, wire up ASSETCATALOG_COMPILER_APPICON_NAME and CFBundleDisplayName on the devicekit-tvosUITests target, and extend patch-tvos-runner.sh to copy the compiled Assets.car and set CFBundleIcons/CFBundleDisplayName on the Runner.app so the tvOS test runner now shows the same Device Kit icon as the iOS one. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
What
The DeviceKit XCUITest runner now builds for tvOS, so the automation stack can drive the tvOS Simulator over the same JSON-RPC interface used for iOS.
Changes
devicekit-tvosscheme and tvOS target in the Xcode project, plusscripts/patch-tvos-runner.shand Makefile targets that build and patch the tvOS runner.device.io.buttonhandler that maps button names toXCUIRemote.Buttonpresses (up, down, left, right, select, menu, home, playPause). tvOS navigates by focus, so there is no touch input.#if os(iOS)in the JSON-RPC dispatcher.DeviceInforeads the screen size fromUIScreen.main.boundson tvOS, since tvOS has no SpringBoard to query.#if os(iOS)so the shared sources compile for both platforms.CFBundleIcons/CFBundleDisplayName).Testing
Built the tvOS runner and ran it against a booted Apple TV 4K simulator, then drove a full profile create and delete flow in a tvOS app. Remote button presses, screenshots, and UI dumps all worked. Verified the Runner.app icon on-device via simulator install.
Related