Skip to content

Commit 90b879e

Browse files
authored
BuildTool: Fix xcodebuild: error: SDK macosx26 cannot be located. (#1260)
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 cf32cb2 commit 90b879e

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
@@ -2264,10 +2264,32 @@ class BuildTool
22642264
if (extract_version.match(file))
22652265
{
22662266
var ver = extract_version.matched(1);
2267-
var split_best = best.split(".");
22682267
var split_ver = ver.split(".");
2269-
if (Std.parseFloat(split_ver[0]) > Std.parseFloat(split_best[0]) || Std.parseFloat(split_ver[1]) > Std.parseFloat(split_best[1]))
2268+
var major_ver = Std.parseFloat(split_ver[0]);
2269+
var minor_ver = Std.parseFloat(split_ver[1]);
2270+
if (Math.isNaN(major_ver) || Math.isNaN(minor_ver))
2271+
{
2272+
// if version is the wrong format, skip it
2273+
continue;
2274+
}
2275+
var split_best = best.split(".");
2276+
var major_best = Std.parseFloat(split_best[0]);
2277+
var minor_best = Std.parseFloat(split_best[1]);
2278+
if (Math.isNaN(major_best) || Math.isNaN(minor_best))
2279+
{
2280+
// shouldn't happen, but just to be safe
2281+
best = ver;
2282+
}
2283+
else if (major_ver > major_best)
2284+
{
2285+
// prefer higher major version
2286+
best = ver;
2287+
}
2288+
else if (major_ver == major_best && minor_ver > minor_best)
2289+
{
2290+
// if major versions are equal, prefer higher minor version
22702291
best = ver;
2292+
}
22712293
}
22722294
}
22732295
if (best!="0.0")

0 commit comments

Comments
 (0)