From 2adfd6ba60ad2e3c7904c00dafc3e8df36657e73 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Tue, 18 Oct 2016 08:34:20 -0700 Subject: [PATCH] Set IPHONE_VER before going to HXCPP --- lime/tools/helpers/IOSHelper.hx | 55 +++++++++++++++++++---------- lime/tools/platforms/IOSPlatform.hx | 12 +++++++ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/lime/tools/helpers/IOSHelper.hx b/lime/tools/helpers/IOSHelper.hx index 3ec4e88d0..01b6f460e 100644 --- a/lime/tools/helpers/IOSHelper.hx +++ b/lime/tools/helpers/IOSHelper.hx @@ -85,33 +85,52 @@ class IOSHelper { } - private static function getIOSVersion (project:HXProject):Void { + public static function getIOSVersion (project:HXProject):Void { - if (!project.environment.exists("IPHONE_VER")) { - if (!project.environment.exists("DEVELOPER_DIR")) { - var proc = new Process("xcode-select", ["--print-path"]); - var developer_dir = proc.stdout.readLine(); - proc.close(); - project.environment.set("DEVELOPER_DIR", developer_dir); - } - var dev_path = project.environment.get("DEVELOPER_DIR") + "/Platforms/iPhoneOS.platform/Developer/SDKs"; + if (!project.environment.exists ("IPHONE_VER") || project.environment.get ("IPHONE_VER") == "4.2") { - if (FileSystem.exists (dev_path)) { - var best = ""; - var files = FileSystem.readDirectory (dev_path); - var extract_version = ~/^iPhoneOS(.*).sdk$/; + if (!project.environment.exists("DEVELOPER_DIR")) { + + var process = new Process ("xcode-select", [ "--print-path" ]); + var developerDir = process.stdout.readLine (); + process.close (); + + project.environment.set ("DEVELOPER_DIR", developerDir); + + } + + var devPath = project.environment.get ("DEVELOPER_DIR") + "/Platforms/iPhoneOS.platform/Developer/SDKs"; + + if (FileSystem.exists (devPath)) { + + var files = FileSystem.readDirectory (devPath); + var extractVersion = ~/^iPhoneOS(.*).sdk$/; + var best = "", version; for (file in files) { - if (extract_version.match (file)) { - var ver = extract_version.matched (1); - if (ver > best) - best = ver; + + if (extractVersion.match (file)) { + + version = extractVersion.matched (1); + + if (Std.parseFloat (version) > Std.parseFloat (best)) { + + best = version; + + } + } + } - if (best != "") + if (best != "") { + project.environment.set ("IPHONE_VER", best); + + } + } + } } diff --git a/lime/tools/platforms/IOSPlatform.hx b/lime/tools/platforms/IOSPlatform.hx index 7e287f23e..866f9cc51 100644 --- a/lime/tools/platforms/IOSPlatform.hx +++ b/lime/tools/platforms/IOSPlatform.hx @@ -124,6 +124,9 @@ class IOSPlatform extends PlatformTarget { } + IOSHelper.getIOSVersion (project); + project.haxedefs.set ("IPHONE_VER", project.environment.get ("IPHONE_VER")); + var context = project.templateContext; context.HAS_ICON = false; @@ -366,6 +369,15 @@ class IOSPlatform extends PlatformTarget { } + IOSHelper.getIOSVersion (project); + var iphoneVer = project.environment.get ("IPHONE_VER"); + + for (command in commands) { + + command.push ("-DIPHONE_VER=" + iphoneVer); + + } + CPPHelper.rebuild (project, commands); }