Skip to content

Commit f234c5a

Browse files
fix: get_app_container returns non-existent path
In case application is not installed on simulator, `xcrun simctl get_app_container ...` command returns some random path that does not exist. In case you install the application after that, the path is not the same as the returned by the command before that. So check if the path exists and return null in case it does not.
1 parent 87dac2f commit f234c5a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/simctl.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import childProcess = require("./child-process");
22
import * as child_process from "child_process";
33
import errors = require("./errors");
44
import * as _ from "lodash";
5+
import * as fs from "fs";
56

67
export class Simctl implements ISimctl {
78

@@ -50,7 +51,9 @@ export class Simctl implements ISimctl {
5051

5152
public async getAppContainer(deviceId: string, appIdentifier: string): Promise<string> {
5253
try {
53-
return await this.spawnAsync("get_app_container", [deviceId, appIdentifier]);
54+
const appContainerPath = await this.spawnAsync("get_app_container", [deviceId, appIdentifier]);
55+
// In case application is not installed on simulator, get_app_container returns some random location. After you installation, the application goes in a different location.
56+
return fs.existsSync(appContainerPath) ? appContainerPath : null;
5457
} catch (e) {
5558
if (e.message.indexOf("No such file or directory") > -1) {
5659
return null;

0 commit comments

Comments
 (0)