Skip to content

Commit

Permalink
IOSHelper: fix lime test ios with Xcode 16 or newer
Browse files Browse the repository at this point in the history
The ios-deploy tool no longer works with new iOS SDKs that don't have DeveloperDiskImage.dmg, but Xcode added new commands that can be used in the terminal to install and launch on connected devices.
  • Loading branch information
joshtynjala committed Dec 2, 2024
1 parent c3b749b commit 837534c
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions src/lime/tools/IOSHelper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -359,21 +359,44 @@ class IOSHelper
applicationPath = workingDirectory + "/build/" + configuration + "-iphoneos/" + project.app.file + ".app";
}

var templatePaths = [
Path.combine(Haxelib.getPath(new Haxelib(#if lime "lime" #else "hxp" #end)), #if lime "templates" #else "" #end)
].concat(project.templatePaths);
var launcher = System.findTemplate(templatePaths, "bin/ios-deploy");
Sys.command("chmod", ["+x", launcher]);

// var xcodeVersion = getXcodeVersion ();

System.runCommand("", launcher, [
"install",
"--noninteractive",
"--debug",
"--bundle",
FileSystem.fullPath(applicationPath)
]);
var xcodeVersion = Std.parseFloat(getXcodeVersion());
if (!Math.isNaN(xcodeVersion) && xcodeVersion >= 16) {
// ios-deploy doesn't work with newer iOS SDKs where it can't
// find DeveloperDiskImage.dmg. however, Xcode 16 adds new
// commands for installing and launching apps on connected
// devices, so we'll prefer those, if available.
var listDevicesOutput = System.runProcess("", "xcrun", ["devicectl", "list", "devices", "--hide-default-columns", "--columns", "Identifier", "--filter", "Platform == 'iOS' AND State == 'connected'"]);
var deviceUUID:String = null;
var ready = false;
for (line in listDevicesOutput.split("\n")) {
if (!ready) {
ready = StringTools.startsWith(line, "----");
continue;
}
deviceUUID = line;
break;
}
if (deviceUUID == null || deviceUUID.length == 0) {
Log.error("No device connected");
return;
}
System.runCommand("", "xcrun", ["devicectl", "device", "install", "app", "--device", deviceUUID, FileSystem.fullPath(applicationPath)]);
System.runCommand("", "xcrun", ["devicectl", "device", "process", "launch", "--console", "--device", deviceUUID, project.meta.packageName]);
} else {
var templatePaths = [
Path.combine(Haxelib.getPath(new Haxelib(#if lime "lime" #else "hxp" #end)), #if lime "templates" #else "" #end)
].concat(project.templatePaths);
var launcher = System.findTemplate(templatePaths, "bin/ios-deploy");
Sys.command("chmod", ["+x", launcher]);

System.runCommand("", launcher, [
"install",
"--noninteractive",
"--debug",
"--bundle",
FileSystem.fullPath(applicationPath)
]);
}
}
}

Expand Down

0 comments on commit 837534c

Please sign in to comment.