-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Summary
When XcodeLocator discovers the Xcode path via xcode-select --print-path (discovery path #3), the XcodeVersion and DTXcode properties are never populated and remain at their default values (0.0.0 and "" respectively).
This causes downstream consumers that rely on XcodeVersion to see 0.0 instead of the actual Xcode version (e.g., 26.2).
Root Cause
In XcodeLocator.TryLocatingXcode(), the three discovery paths handle version parsing differently:
- Env var (line ~109): calls
TryLocatingSpecificXcode-> parsesversion.plist-> setsXcodeVersion✅ - Settings file (line ~120): calls
TryLocatingSpecificXcode-> parsesversion.plist-> setsXcodeVersion✅ - xcode-select (line ~129): calls
TryGetSystemXcode-> only returns a path string, does not callTryLocatingSpecificXcode->XcodeVersionstays at0.0.0❌
TryGetSystemXcode is a static method that runs xcode-select --print-path and returns the path, but it never calls TryLocatingSpecificXcode which is responsible for reading Contents/version.plist and populating XcodeVersion and DTXcode.
Reproduction
- Have no settings file (
~/Library/Preferences/maui/Settings.plistor~/Library/Preferences/Xamarin/Settings.plist) - Have
MD_APPLE_SDK_ROOTunset - Have a valid Xcode configured via
xcode-select -s - Create an
XcodeLocatorand callTryLocatingXcode(null) - Observe
XcodeVersionis0.0.0instead of the actual version
Suggested Fix
Route the xcode-select path through TryLocatingSpecificXcode like the other two paths already do. In TryLocatingXcode(), around line 129, change:
csharp // 3. Not optional if (TryGetSystemXcode (log, out location)) {
to:
csharp // 3. Not optional if (TryGetSystemXcode (log, out var systemXcodePath) && TryLocatingSpecificXcode (systemXcodePath, out location)) {
This also validates the Xcode bundle from xcode-select (checking for version.plist and Info.plist), which the current code does not do.