Skip to content

[msbuild] Improve diagnostics when simulator runtimes aren't available, Fixes #25298#25483

Open
rolfbjarne wants to merge 6 commits into
mainfrom
dev/rolf/issue-25298-no-sim-diagnostics
Open

[msbuild] Improve diagnostics when simulator runtimes aren't available, Fixes #25298#25483
rolfbjarne wants to merge 6 commits into
mainfrom
dev/rolf/issue-25298-no-sim-diagnostics

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

Apple's Xcode tools (actool, ibtool, etc.) require the simulator runtime even when building for physical devices. When the runtime is missing or the wrong version, these tools fail with unhelpful errors or hang indefinitely.

Changes

After a tool failure, run xcrun simctl --json-output=<file> list runtimes to check whether the required simulator runtime is installed. If missing, emit a clear error (E7170) with instructions on how to install it.

Additionally, detect simulator runtime version mismatch errors in tool output (e.g. No simulator runtime version from [...] available to use with iphonesimulator SDK version ...) and emit E7172 suggesting the user update their simulator runtime.

The simctl check uses a 1-minute timeout to avoid hanging, and results are cached per platform/SdkDevPath.

New diagnostics

  • E7170: Simulator runtime not installed (post-failure simctl check)
  • W7171: Unable to determine simulator runtime availability
  • E7172: Tool error indicates incompatible simulator runtime version

Fixes #25298

🤖 Pull request created by Copilot

Apple's Xcode tools (actool, ibtool, etc.) require the simulator runtime
even when building for physical devices. When the runtime is missing or
the wrong version, these tools fail with unhelpful errors or hang
indefinitely.

After a tool failure, run 'xcrun simctl --json-output=<file> list runtimes'
to check whether the required simulator runtime is installed. If missing,
emit a clear error (E7170) with instructions on how to install it.

Additionally, detect simulator runtime version mismatch errors in tool
output (e.g. 'No simulator runtime version from [...] available to use
with iphonesimulator SDK version ...') and emit E7172 suggesting the user
update their simulator runtime.

The simctl check uses a 1-minute timeout (via a linked CancellationTokenSource)
to avoid hanging, and results are cached per platform/SdkDevPath.

New diagnostics:
- E7170: Simulator runtime not installed (post-failure simctl check)
- W7171: Unable to determine simulator runtime availability
- E7172: Tool error indicates incompatible simulator runtime version

Fixes #25298

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
If simctl exits with a non-zero exit code, don't cache anything so the
check will be retried on the next failure. Caching 'true' would suppress
future diagnostics even if the runtime is genuinely missing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member Author

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

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

Review Summary

LGTM — Well-structured post-failure diagnostic check. The approach of running simctl only after a tool failure is sound and avoids unnecessary overhead on successful builds. Error handling (timeout, cancellation, exception) is thorough and correct.

CI: Still pending — verify green before merge.

Positive callouts

  • Good use of ConcurrentDictionary for the static cache
  • Correct handling of user cancellation vs timeout (linked CTS with filtered catch blocks)
  • Writing JSON to file (--json-output=) instead of parsing stdout is robust
  • Cache key includes SdkDevPath — handles multi-Xcode environments correctly
  • Not caching failures from simctl itself allows retry on transient issues

Issues by severity

  • ⚠️ warning: 1
  • 💡 suggestion: 1

Comment thread msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeCompilerToolTask.cs
Comment thread msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeCompilerToolTask.cs
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne marked this pull request as ready for review May 22, 2026 09:03
@rolfbjarne rolfbjarne requested a review from mauroa as a code owner May 22, 2026 09:03
Copilot AI review requested due to automatic review settings May 22, 2026 09:03
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 improves MSBuild task diagnostics for Xcode tool failures that are commonly caused by missing or incompatible simulator runtimes (even when building for device), by adding a post-failure simctl check and new localized messages.

Changes:

  • Add a post-tool-failure check that queries installed simulator runtimes via xcrun simctl ... and emits a targeted error when the required runtime is missing.
  • Detect simulator runtime version mismatch strings in tool-reported errors and emit a targeted error suggesting updating the runtime.
  • Add new localized diagnostics (E7170/W7171/E7172) describing missing/unknown/mismatched simulator runtime scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeCompilerToolTask.cs Adds simulator runtime availability checks after tool failures and adds version-mismatch detection for improved error reporting.
msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx Introduces new localized strings for the new diagnostics (E7170/W7171/E7172).
Comments suppressed due to low confidence (2)

msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeCompilerToolTask.cs:215

  • CheckSimulatorRuntimeAvailable only caches successful simctl parses. If simctl returns non-zero or times out, the method will retry on every subsequent tool failure, potentially adding repeated 1-minute delays in a single build (exactly the scenario this code is meant to improve). Consider caching a third state ("unknown") per platform/SdkDevPath so W7171 (or the timeout) is only incurred once per build.
				if (rv.ExitCode != 0) {
					Log.LogWarning (MSBStrings.W7171, simPlatform);
					return;

msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeCompilerToolTask.cs:403

  • IsSimulatorRuntimeVersionError currently flags any error containing the substring "simulator runtime". This is very broad and can emit E7172 for unrelated tool errors that happen to mention simulator runtimes, producing misleading guidance. Since the intent is to detect version mismatch errors like "No simulator runtime version from ... available to use with ... SDK version ...", match that more specific phrasing.
		static bool IsSimulatorRuntimeVersionError (string message)
		{
			return message.IndexOf ("simulator runtime", StringComparison.OrdinalIgnoreCase) >= 0;
		}

Comment thread msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeCompilerToolTask.cs
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…no-sim-diagnostics

# Conflicts:
#	msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #c62b8a9] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: c62b8a92a68241439e7880a15c9d741c6debd043 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #c62b8a9] Build passed (Build packages) ✅

Pipeline on Agent
Hash: c62b8a92a68241439e7880a15c9d741c6debd043 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: c62b8a92a68241439e7880a15c9d741c6debd043 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #c62b8a9] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: c62b8a92a68241439e7880a15c9d741c6debd043 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🔥 [CI Build #c62b8a9] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 1 tests failed, 182 tests passed.

Failures

❌ monotouch tests (tvOS)

1 tests failed, 17 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Release (compat inline dlfcn): Failed

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: c62b8a92a68241439e7880a15c9d741c6debd043 [PR build]

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve diagnostics when the correct simulators aren't available.

4 participants