From 83a5f400e61ec500e4d50083abbaa367e5fb14c2 Mon Sep 17 00:00:00 2001 From: Rui Marinho Date: Fri, 29 May 2026 16:14:28 +0100 Subject: [PATCH 1/2] Guard against setting empty XCODE_DEVELOPER_DIR_PATH env var Only set the XCODE_DEVELOPER_DIR_PATH environment variable when DeveloperRoot is non-empty. If it is empty (defensive case), explicitly clear the env var to avoid leaving a stale value from a prior Init() call. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Xamarin.MacDev/AppleSdkSettings.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Xamarin.MacDev/AppleSdkSettings.cs b/Xamarin.MacDev/AppleSdkSettings.cs index 8262df3..ced1182 100644 --- a/Xamarin.MacDev/AppleSdkSettings.cs +++ b/Xamarin.MacDev/AppleSdkSettings.cs @@ -194,7 +194,10 @@ public static void Init () XcodePath = xcode; DeveloperRoot = devroot; DeveloperRootVersionPlist = vplist; - Environment.SetEnvironmentVariable ("XCODE_DEVELOPER_DIR_PATH", DeveloperRoot); + if (!string.IsNullOrEmpty (DeveloperRoot)) + Environment.SetEnvironmentVariable ("XCODE_DEVELOPER_DIR_PATH", DeveloperRoot); + else + Environment.SetEnvironmentVariable ("XCODE_DEVELOPER_DIR_PATH", null); } else { SetInvalid (); return; From 09f4a312bba05f03ab576c1aede455a1326f2556 Mon Sep 17 00:00:00 2001 From: Rui Marinho Date: Mon, 1 Jun 2026 11:48:46 +0100 Subject: [PATCH 2/2] Revert unnecessary null check per reviewer feedback The foundSdk guard already ensures DeveloperRoot is non-null/empty, making the defensive check redundant. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Xamarin.MacDev/AppleSdkSettings.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Xamarin.MacDev/AppleSdkSettings.cs b/Xamarin.MacDev/AppleSdkSettings.cs index ced1182..8262df3 100644 --- a/Xamarin.MacDev/AppleSdkSettings.cs +++ b/Xamarin.MacDev/AppleSdkSettings.cs @@ -194,10 +194,7 @@ public static void Init () XcodePath = xcode; DeveloperRoot = devroot; DeveloperRootVersionPlist = vplist; - if (!string.IsNullOrEmpty (DeveloperRoot)) - Environment.SetEnvironmentVariable ("XCODE_DEVELOPER_DIR_PATH", DeveloperRoot); - else - Environment.SetEnvironmentVariable ("XCODE_DEVELOPER_DIR_PATH", null); + Environment.SetEnvironmentVariable ("XCODE_DEVELOPER_DIR_PATH", DeveloperRoot); } else { SetInvalid (); return;