From db729da78429641f201117c6b221abaa6bccc8d6 Mon Sep 17 00:00:00 2001 From: Christian Howe Date: Wed, 17 Apr 2024 19:14:58 -0700 Subject: [PATCH] Fix Xcode C++ include path --- src/Core/Toolchains/XcodeToolchain.cs | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Core/Toolchains/XcodeToolchain.cs b/src/Core/Toolchains/XcodeToolchain.cs index 89e03f36b1..ef8589c03f 100644 --- a/src/Core/Toolchains/XcodeToolchain.cs +++ b/src/Core/Toolchains/XcodeToolchain.cs @@ -27,16 +27,34 @@ public static string GetXcodeToolchainPath() return toolchainPath; } + public static string GetXcodeSDKPath() { + return Path.Combine( + GetXcodePath(), + "Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" + ); + } + public static string GetXcodeCppIncludesFolder() { var toolchainPath = GetXcodeToolchainPath(); + var sdkPath = GetXcodeSDKPath(); - var includePath = Path.Combine(toolchainPath, "usr/include/c++/v1"); + var includePathSuffix = "usr/include/c++/v1"; + var oldIncludePath = Path.Combine(toolchainPath, includePathSuffix); + var newIncludePath = Path.Combine(sdkPath, includePathSuffix); - if (includePath == null || !Directory.Exists(includePath)) - throw new Exception($"Could not find a valid C++ include folder: {includePath}"); + if (newIncludePath != null && Directory.Exists(newIncludePath)) + { + return newIncludePath; + } + + if (oldIncludePath != null && Directory.Exists(oldIncludePath)) + { + return oldIncludePath; + } - return includePath; + throw new Exception( + $"Could not find a valid C++ include folder in either {oldIncludePath} or {newIncludePath}"); } public static string GetXcodeBuiltinIncludesFolder() @@ -107,4 +125,4 @@ private static string GetXcodePathFromFileSystem() return toolchainPath; } } -} \ No newline at end of file +}