native-run
Advanced tools
Comparing version 1.7.2 to 1.7.3
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.runOnDevice = exports.getConnectedDevices = void 0; | ||
const child_process_1 = require("child_process"); | ||
const Debug = require("debug"); | ||
@@ -36,18 +37,51 @@ const fs_1 = require("fs"); | ||
await process_1.wait(200); | ||
const debugServerClient = await launchApp(clientManager, appInfo); | ||
if (waitForApp) { | ||
process_1.onBeforeExit(async () => { | ||
// causes continue() to return | ||
debugServerClient.halt(); | ||
// give continue() time to return response | ||
await process_1.wait(64); | ||
}); | ||
debug(`Waiting for app to close...\n`); | ||
const result = await debugServerClient.continue(); | ||
// TODO: I have no idea what this packet means yet (successful close?) | ||
// if not a close (ie, most likely due to halt from onBeforeExit), then kill the app | ||
if (result !== 'W00') { | ||
await debugServerClient.kill(); | ||
try { | ||
const debugServerClient = await launchApp(clientManager, appInfo); | ||
if (waitForApp) { | ||
process_1.onBeforeExit(async () => { | ||
// causes continue() to return | ||
debugServerClient.halt(); | ||
// give continue() time to return response | ||
await process_1.wait(64); | ||
}); | ||
debug(`Waiting for app to close...\n`); | ||
const result = await debugServerClient.continue(); | ||
// TODO: I have no idea what this packet means yet (successful close?) | ||
// if not a close (ie, most likely due to halt from onBeforeExit), then kill the app | ||
if (result !== 'W00') { | ||
await debugServerClient.kill(); | ||
} | ||
} | ||
} | ||
catch { | ||
// if launching app throws, try with devicectl, but requires Xcode 15 | ||
const [xcodeVersion] = xcode_1.getXcodeVersionInfo(); | ||
if (Number(xcodeVersion) >= 15) { | ||
const launchResult = child_process_1.spawn('xcrun', [ | ||
'devicectl', | ||
'device', | ||
'process', | ||
'launch', | ||
'--device', | ||
udid, | ||
bundleId, | ||
]); | ||
return new Promise((resolve, reject) => { | ||
launchResult.on('close', code => { | ||
if (code === 0) { | ||
resolve(); | ||
} | ||
else { | ||
reject(new errors_1.Exception(`There was an error launching app on device`)); | ||
} | ||
}); | ||
launchResult.on('error', err => { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
else { | ||
throw new errors_1.Exception(`running on iOS 17 devices requires Xcode 15 and later`); | ||
} | ||
} | ||
} | ||
@@ -54,0 +88,0 @@ finally { |
{ | ||
"name": "native-run", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "A CLI for running apps on iOS/Android devices and simulators/emulators", | ||
@@ -53,2 +53,3 @@ "bin": { | ||
"@semantic-release/git": "^10.0.1", | ||
"@types/babel__traverse": "7.17.1", | ||
"@types/debug": "^4.1.7", | ||
@@ -55,0 +56,0 @@ "@types/elementtree": "^0.1.1", |
2182129
5232
21
10