Skip to content

Commit 3f923b1

Browse files
author
Christian Howe
authored
Fix Xcode C++ include path (#1844)
1 parent 81e0a93 commit 3f923b1

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/Core/Toolchains/XcodeToolchain.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,34 @@ public static string GetXcodeToolchainPath()
2727
return toolchainPath;
2828
}
2929

30+
public static string GetXcodeSDKPath() {
31+
return Path.Combine(
32+
GetXcodePath(),
33+
"Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
34+
);
35+
}
36+
3037
public static string GetXcodeCppIncludesFolder()
3138
{
3239
var toolchainPath = GetXcodeToolchainPath();
40+
var sdkPath = GetXcodeSDKPath();
3341

34-
var includePath = Path.Combine(toolchainPath, "usr/include/c++/v1");
42+
var includePathSuffix = "usr/include/c++/v1";
43+
var oldIncludePath = Path.Combine(toolchainPath, includePathSuffix);
44+
var newIncludePath = Path.Combine(sdkPath, includePathSuffix);
3545

36-
if (includePath == null || !Directory.Exists(includePath))
37-
throw new Exception($"Could not find a valid C++ include folder: {includePath}");
46+
if (newIncludePath != null && Directory.Exists(newIncludePath))
47+
{
48+
return newIncludePath;
49+
}
50+
51+
if (oldIncludePath != null && Directory.Exists(oldIncludePath))
52+
{
53+
return oldIncludePath;
54+
}
3855

39-
return includePath;
56+
throw new Exception(
57+
$"Could not find a valid C++ include folder in either {oldIncludePath} or {newIncludePath}");
4058
}
4159

4260
public static string GetXcodeBuiltinIncludesFolder()
@@ -107,4 +125,4 @@ private static string GetXcodePathFromFileSystem()
107125
return toolchainPath;
108126
}
109127
}
110-
}
128+
}

0 commit comments

Comments
 (0)