Skip to content

Commit 87013f2

Browse files
committed
BuildTool: Fix xcodebuild: error: SDK macosx26 cannot be located.
My SDKs directory contains three entries: MacOSX.sdk MacOSX26.0.sdk MacOSX26.sdk The current SDK version detection in hxcpp is preferring MacOSX26.sdk over MacOSX26.0.sdk. This is causing MACOSX_VER to be set to 26. However, xcodebuild seems to want both major and minor parts of the version to be specified, so MACOSX_VER should be set to 26.0 instead. This change checks if the current best's minor version is parsed as NaN when the major versions match, which results in a real float value for the minor version to be preferred.
1 parent 1618253 commit 87013f2

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

tools/hxcpp/BuildTool.hx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,10 +2203,32 @@ class BuildTool
22032203
if (extract_version.match(file))
22042204
{
22052205
var ver = extract_version.matched(1);
2206-
var split_best = best.split(".");
22072206
var split_ver = ver.split(".");
2208-
if (Std.parseFloat(split_ver[0]) > Std.parseFloat(split_best[0]) || Std.parseFloat(split_ver[1]) > Std.parseFloat(split_best[1]))
2207+
var major_ver = Std.parseFloat(split_ver[0]);
2208+
var minor_ver = Std.parseFloat(split_ver[1]);
2209+
if (Math.isNaN(major_ver) || Math.isNaN(minor_ver))
2210+
{
2211+
// if version is the wrong format, skip it
2212+
continue;
2213+
}
2214+
var split_best = best.split(".");
2215+
var major_best = Std.parseFloat(split_best[0]);
2216+
var minor_best = Std.parseFloat(split_best[1]);
2217+
if (Math.isNaN(major_best) || Math.isNaN(minor_best))
2218+
{
2219+
// shouldn't happen, but just to be safe
2220+
best = ver;
2221+
}
2222+
else if (major_ver > major_best)
2223+
{
2224+
// prefer higher major version
2225+
best = ver;
2226+
}
2227+
else if (major_ver == major_best && minor_ver > minor_best)
2228+
{
2229+
// if major versions are equal, prefer higher minor version
22092230
best = ver;
2231+
}
22102232
}
22112233
}
22122234
if (best!="0.0")

0 commit comments

Comments
 (0)