[msbuild] Improve diagnostics when simulator runtimes aren't available, Fixes #25298#25483
[msbuild] Improve diagnostics when simulator runtimes aren't available, Fixes #25298#25483rolfbjarne wants to merge 6 commits into
Conversation
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>
rolfbjarne
left a comment
There was a problem hiding this comment.
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
ConcurrentDictionaryfor 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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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
CheckSimulatorRuntimeAvailableonly 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
IsSimulatorRuntimeVersionErrorcurrently 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;
}
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…no-sim-diagnostics # Conflicts: # msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
✅ [PR Build #c62b8a9] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #c62b8a9] Build passed (Build packages) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #c62b8a9] Build passed (Build macOS tests) ✅Pipeline on Agent |
🔥 [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
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
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 runtimesto 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
Fixes #25298
🤖 Pull request created by Copilot