Fix ArgumentNullException in AppleSdkSettings when no settings file exists#179
Merged
Conversation
…xists The static constructor iterates over SettingsPathCandidates looking for an existing settings file (maui/Settings.plist or Xamarin/Settings.plist). When neither file exists — which happens on fresh machines or CI agents that have never configured an Xcode path — SettingsPath remains null. This causes Directory.CreateDirectory(Path.GetDirectoryName(null)) to throw System.ArgumentNullException at line 145 (parameter 'path'), which propagates as a TypeInitializationException and ultimately fails the DetectSdkLocations MSBuild task, breaking all builds. Fix: after the loop, if no existing settings file was found, default SettingsPath to the first candidate (~/Library/Preferences/maui/Settings.plist). This ensures the directory is created and Init() can proceed to discover Xcode via xcode-select or other fallback mechanisms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rolfbjarne
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The static constructor iterates over SettingsPathCandidates looking for an existing settings file (maui/Settings.plist or Xamarin/Settings.plist). When neither file exists — which happens on fresh machines or CI agents that have never configured an Xcode path — SettingsPath remains null.
This causes Directory.CreateDirectory(Path.GetDirectoryName(null)) to throw System.ArgumentNullException at line 145 (parameter 'path'), which propagates as a TypeInitializationException and ultimately fails the DetectSdkLocations MSBuild task, breaking all builds.
Fix: after the loop, if no existing settings file was found, default SettingsPath to the first candidate (~/Library/Preferences/maui/Settings.plist). This ensures the directory is created and Init() can proceed to discover Xcode via xcode-select or other fallback mechanisms.