Skip to content

Commit 077af9c

Browse files
fix: unable to install application every other time with Xcode 10
When using Xcode 10, the `xcrun simctl install ...` command fails every other time with error: ``` Error: Command xcrun with arguments simctl install 5516E083-C749-47A7-A6FC-2EE2E414D025 /Users/vladimirov/Work/nativescript-cli/scratch/app1/platforms/ios/build/emulator/app1.app failed with exit code 1. Error output: An error was encountered processing the command (domain=IXUserPresentableErrorDomain, code=1): This app could not be installed at this time. Failed to load Info.plist from bundle at path /Users/vladimirov/Library/Developer/CoreSimulator/Devices/5516E083-C749-47A7-A6FC-2EE2E414D025/data/Library/Caches/com.apple.mobile.installd.staging/temp.ZdmYQa/extracted/Payload/app1.app Failed to load Info.plist from bundle at path /Users/vladimirov/Library/Developer/CoreSimulator/Devices/5516E083-C749-47A7-A6FC-2EE2E414D025/data/Library/Caches/com.apple.mobile.installd.staging/temp.ZdmYQa/extracted/Payload/app1.app Underlying error (domain=MIInstallerErrorDomain, code=35): Failed to load Info.plist from bundle at path /Users/vladimirov/Library/Developer/CoreSimulator/Devices/5516E083-C749-47A7-A6FC-2EE2E414D025/data/Library/Caches/com.apple.mobile.installd.staging/temp.ZdmYQa/extracted/Payload/app1.app ``` It looks like during install of the application, the content of the built `.app` is extracted to a temp folder in some cases. While the installation is in progress, Xcode decides it is done and deletes the temp dir. However, the package is installed on device, but it is still loading some data from the package that is installed (the temp dir). It fails, as it searches for Info.plist file in the package we've installed, but it is not there. So the installation process fails and app remains on device with inconsitent state. Retrying the operation fixes the behavior.
1 parent cec4452 commit 077af9c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/iphone-simulator-xcode-simctl.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
4949

5050
this.startSimulator(options, device);
5151
if (!options.skipInstall) {
52-
this.simctl.install(device.id, applicationPath);
52+
await this.installApplication(device.id, applicationPath);
5353
}
5454

5555
return this.simctl.launch(device.id, applicationIdentifier, options);
@@ -73,8 +73,12 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
7373
return common.getInstalledApplications(deviceId);
7474
}
7575

76-
public installApplication(deviceId: string, applicationPath: string): Promise<void> {
77-
return this.simctl.install(deviceId, applicationPath);
76+
public async installApplication(deviceId: string, applicationPath: string): Promise<void> {
77+
try {
78+
await this.simctl.install(deviceId, applicationPath);
79+
} catch (err) {
80+
await this.simctl.install(deviceId, applicationPath);
81+
}
7882
}
7983

8084
public uninstallApplication(deviceId: string, appIdentifier: string): Promise<void> {
@@ -196,7 +200,7 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
196200
if (!device && options.device) {
197201
await this.verifyDevice(options.device);
198202
}
199-
203+
200204
device = device || await this.getDeviceToRun(options);
201205

202206
// In case the id is undefined, skip verification - we'll start default simulator.
@@ -259,8 +263,4 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
259263

260264
return _.find(availableDevices, { id: deviceId });
261265
}
262-
263-
private killSimulator(): void {
264-
childProcess.execSync("pkill -9 -f Simulator");
265-
}
266266
}

0 commit comments

Comments
 (0)