Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 19, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

XHarness crashes during connectToDevice when encountering simulator runtimes with state "Unusable" (e.g., invalid signature errors). This prevents iOS UITests from running.

Added CleanupUnusableRuntimes() in eng/devices/ios.cake that:

  • Queries xcrun simctl runtime list -j to enumerate all simulator runtimes
  • Identifies runtimes with "state" : "Unusable"
  • Deletes them via xcrun simctl runtime delete before XHarness invocation
  • Logs warnings on failure to avoid breaking builds

The cleanup runs automatically in GetSimulators() before calling xharness apple simulators install.

Issues Fixed

Fixes https://dev.azure.com/xamarin/public/_build/results?buildId=154089 (issue reported via build logs showing XHarness encountering unusable runtime 8728D520-0F86-4227-AE03-716249BBB18C with error "(-67061 invalid signature)")

Workaround for Xharness issue: dotnet/xharness#1500 -- once this issue is fixed, this change can be reverted.

Original prompt

This section details on the original issue you should resolve

<issue_title>[UITests][iOS] connectToDevice fails when checking if simulator is installed</issue_title>
<issue_description>Build logs: https://dev.azure.com/xamarin/public/_build/results?buildId=154089&view=logs&j=72a1bc6b-6e49-539f-11ef-42d638c466c3&t=af93ca54-ac95-5c13-8456-9efd54a38da7

Relevant part of the logs:

2025-11-19T10:46:59.4134940Z 
2025-11-19T10:46:59.4135440Z ========================================
2025-11-19T10:46:59.4135810Z connectToDevice
2025-11-19T10:46:59.4136110Z ========================================
2025-11-19T10:46:59.4136570Z �[37mExecuting task: �[0m�[37;1mconnectToDevice�[0m
2025-11-19T10:46:59.4162430Z Cleaning up...
2025-11-19T10:46:59.4162830Z Deleting XHarness simulator if exists...
2025-11-19T10:46:59.4236790Z Could not resolve path for tool "simctl" using these directories: /usr/local/microsoft/powershell/7,/Users/builder/azdo/_work/_tool/node/20.3.1/x64/bin,/Users/builder/azdo/_work/1/s/.dotnet,/Users/builder/.dotnet/tools,/Users/builder/azdo/_work/_tool/dotnet,/usr/local/bin,/usr/local/share/dotnet,~/.dotnet/tools,/Library/Frameworks/Mono.framework/Versions/Current/Commands,/usr/bin,/bin,/usr/sbin,/sbin
2025-11-19T10:46:59.4261210Z �[37mExecuting: �[0m�[37;1m/Applications/Xcode.app/Contents/Developer/usr/bin/simctl list devices  --json�[0m
2025-11-19T10:46:59.8261300Z {
2025-11-19T10:46:59.8261850Z   "devices" : {
2025-11-19T10:46:59.8262190Z     "com.apple.CoreSimulator.SimRuntime.tvOS-26-0" : [
2025-11-19T10:46:59.8262340Z 
2025-11-19T10:46:59.8262610Z     ],
2025-11-19T10:46:59.8262870Z     "com.apple.CoreSimulator.SimRuntime.watchOS-26-0" : [
2025-11-19T10:46:59.8263060Z 
2025-11-19T10:46:59.8263270Z     ],
2025-11-19T10:46:59.8263560Z     "com.apple.CoreSimulator.SimRuntime.iOS-26-0" : [
2025-11-19T10:46:59.8263680Z 
2025-11-19T10:46:59.8263920Z     ]
2025-11-19T10:46:59.8264140Z   }
2025-11-19T10:46:59.8264380Z }
2025-11-19T10:46:59.8844980Z �[37;1mGetting simulators for version �[0m�[44m�[37;1mios-simulator-64_18.4�[0m
2025-11-19T10:46:59.8860420Z �[37mExecuting: �[0m�[37;1m/Users/builder/azdo/_work/1/s/.dotnet/dotnet --diagnostics tool run xharness apple simulators install "ios-simulator-64_18.4" --verbosity="Debug"�[0m
2025-11-19T10:47:00.8057080Z [10.0.0-prerelease.25506.2+5b5722171c6c28f6c9f6b6148f148199b9dd0f5b] XHarness command issued: apple simulators install ios-simulator-64_18.4 --verbosity=Debug
2025-11-19T10:47:01.3757260Z �[40m�[37mdbug�[39m�[22m�[49m: 
2025-11-19T10:47:01.3757760Z       
2025-11-19T10:47:01.3758320Z �[40m�[37mdbug�[39m�[22m�[49m: Running /usr/libexec/PlistBuddy -c "Print :DTXcode" /Applications/Xcode_26.0.1.app/Contents/Info.plist
2025-11-19T10:47:01.3758650Z       
2025-11-19T10:47:01.3885760Z �[40m�[37mdbug�[39m�[22m�[49m: Process PlistBuddy exited with 0
2025-11-19T10:47:01.3886270Z       
2025-11-19T10:47:01.3907790Z �[40m�[32minfo�[39m�[22m�[49m: File '/var/folders/ys/f8hv6gcn2yg1mhbgld5qy1q80000gn/T/simulator-installer/index-26.0.0.dvtdownloadableindex' already exists, skipped download
2025-11-19T10:47:01.3914030Z �[40m�[37mdbug�[39m�[22m�[49m: 
2025-11-19T10:47:01.3914750Z       
2025-11-19T10:47:01.3915330Z �[40m�[37mdbug�[39m�[22m�[49m: Running plutil -convert xml1 -o - /var/folders/ys/f8hv6gcn2yg1mhbgld5qy1q80000gn/T/simulator-installer/index-26.0.0.dvtdownloadableindex
2025-11-19T10:47:01.3915720Z       
2025-11-19T10:47:01.6338680Z �[40m�[37mdbug�[39m�[22m�[49m: Process plutil exited with 0
2025-11-19T10:47:01.6339190Z       
2025-11-19T10:47:01.7079240Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.iPhoneSimulatorSDK12_4'
2025-11-19T10:47:01.7080550Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.AppleTVSimulatorSDK12_4'
2025-11-19T10:47:01.7081070Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.iPhoneSimulatorSDK13_0'
2025-11-19T10:47:01.7081500Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.iPhoneSimulatorSDK13_1'
2025-11-19T10:47:01.7082180Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.WatchSimulatorSDK6_0'
2025-11-19T10:47:01.7082720Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.AppleTVSimulatorSDK13_0'
2025-11-19T10:47:01.7083320Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.AppleTVSimulatorSDK13_2'
2025-11-19T10:47:01.7083750Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.iPhoneSimulatorSDK13_2'
2025-11-19T10:47:01.7084200Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.iPhoneSimulatorSDK13_3'
2025-11-19T10:47:01.7084620Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.WatchSimulatorSDK6_1'
2025-11-19T10:47:01.7085070Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.AppleTVSimulatorSDK13_3'
2025-11-19T10:47:01.7085480Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.iPhoneSimulatorSDK13_4'
2025-11-19T10:47:01.7085930Z �[40m�[37mdbug�[39m�[22m�[49m: Skipping 'com.apple.pkg.iPhoneSimulatorSDK13_5'
2025-11-19T10:47:01.7086350Z �[40m�[37md...

</details>

- Fixes dotnet/maui#32735

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

When XHarness tries to check if a simulator runtime is installed, it can encounter
unusable runtime disk images (e.g., with invalid signatures). This causes XHarness
to fail during the connectToDevice phase.

This fix adds a CleanupUnusableRuntimes() function that:
1. Queries all simulator runtimes using 'xcrun simctl runtime list -j'
2. Parses the output to find runtimes with state "Unusable"
3. Deletes those unusable runtimes before calling XHarness

This prevents XHarness from encountering and failing on unusable runtimes.

Fixes issue where iOS UITests fail with "(-67061 invalid signature)" errors.

Co-authored-by: simonrozsival <[email protected]>
Copilot AI changed the title [WIP] Fix connectToDevice failure in iOS UITests Fix iOS UITest failure when unusable simulator runtimes are present Nov 19, 2025
Copilot AI requested a review from simonrozsival November 19, 2025 12:42
Copilot finished work on behalf of simonrozsival November 19, 2025 12:43
@simonrozsival
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@simonrozsival simonrozsival changed the title Fix iOS UITest failure when unusable simulator runtimes are present [Testing] Fix iOS UITest failure when unusable simulator runtimes are present Nov 19, 2025
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.

2 participants