diff --git a/src/lime/tools/IOSHelper.hx b/src/lime/tools/IOSHelper.hx index a8321a082a..b7c7edf4aa 100644 --- a/src/lime/tools/IOSHelper.hx +++ b/src/lime/tools/IOSHelper.hx @@ -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) + ]); + } } }