Commit fbef955c authored by Chinmay Garde's avatar Chinmay Garde

Update IOSDevice::startApp for precompilation

parent b7e388c5
...@@ -95,8 +95,7 @@ class IOSDevice extends Device { ...@@ -95,8 +95,7 @@ class IOSDevice extends Device {
'To copy files to iOS devices, please install ios-deploy. ' 'To copy files to iOS devices, please install ios-deploy. '
'You can do this using homebrew as follows:\n' 'You can do this using homebrew as follows:\n'
'\$ brew tap flutter/flutter\n' '\$ brew tap flutter/flutter\n'
'\$ brew install ios-deploy', '\$ brew install ios-deploy');
'Copying files to iOS devices is not currently supported on Linux.');
} }
static List<IOSDevice> getAttachedDevices([IOSDevice mockIOS]) { static List<IOSDevice> getAttachedDevices([IOSDevice mockIOS]) {
...@@ -178,7 +177,7 @@ class IOSDevice extends Device { ...@@ -178,7 +177,7 @@ class IOSDevice extends Device {
@override @override
bool isAppInstalled(ApplicationPackage app) { bool isAppInstalled(ApplicationPackage app) {
try { try {
String apps = runCheckedSync([installerPath, '-l']); String apps = runCheckedSync([installerPath, '--list-apps']);
if (new RegExp(app.id, multiLine: true).hasMatch(apps)) { if (new RegExp(app.id, multiLine: true).hasMatch(apps)) {
return true; return true;
} }
...@@ -188,24 +187,52 @@ class IOSDevice extends Device { ...@@ -188,24 +187,52 @@ class IOSDevice extends Device {
return false; return false;
} }
Future<bool> buildPrecompiledApplication(ApplicationPackage app) async {
int result = await runCommandAndStreamOutput([
'/usr/bin/env', 'xcrun', 'xcodebuild', '-target', 'Runner', '-configuration', 'Release'
], workingDirectory: app.localPath);
return result == 0;
}
@override @override
Future<bool> startApp(ApplicationPackage app) async { Future<bool> startApp(ApplicationPackage app) async {
if (!isAppInstalled(app)) { logging.fine("Attempting to build and install ${app.name} on $id");
// Step 1: Install the precompiled application if necessary
bool buildResult = await buildPrecompiledApplication(app);
if (!buildResult) {
logging.severe('Could not build the precompiled application for the device');
return false; return false;
} }
// idevicedebug hangs forever after launching the app, so kill it after
// giving it plenty of time to send the launch command. // Step 2: Check that the application exists at the specified path
return await runAndKill( Directory bundle = new Directory(path.join(app.localPath, 'build', 'Release-iphoneos', 'Runner.app'));
[debuggerPath, 'run', app.id],
new Duration(seconds: 3) bool bundleExists = await bundle.exists();
).then( if (!bundleExists) {
(_) { logging.severe('Could not find the built application bundle at ${bundle.path}');
return true;
}, onError: (e) {
logging.info('Failure running $debuggerPath: ', e);
return false; return false;
} }
);
// Step 3: Attempt to install the application on the device
int installationResult = await runCommandAndStreamOutput([
'/usr/bin/env',
'ios-deploy',
'--id',
id,
'--bundle',
bundle.path,
]);
if (installationResult != 0) {
logging.severe('Could not install ${bundle.path} on $id');
return false;
}
logging.fine('Installation successful');
return true;
} }
@override @override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment