Skip to content

Commit

Permalink
Fix Xcode C++ include path (#1844)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjhowedev authored Apr 22, 2024
1 parent 81e0a93 commit 3f923b1
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/Core/Toolchains/XcodeToolchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -107,4 +125,4 @@ private static string GetXcodePathFromFileSystem()
return toolchainPath;
}
}
}
}

0 comments on commit 3f923b1

Please sign in to comment.