iOS Simulator: Attempt 'sideloading' the updated Flutter application if the application runner is already up
* This makes the turnaround times < 2 seconds on the iOS simulator. * Also bumps the engine to use the new engine required to support the flags.
This commit is contained in:
parent
0d498374dc
commit
9f4fdcb866
2
bin/cache/engine.version
vendored
2
bin/cache/engine.version
vendored
@ -1 +1 @@
|
|||||||
3a48f9c90b6406b10d5a8a1897c147c71ccc59ba
|
d474e9d2b60a9cb111c09844c10081b68bde9252
|
||||||
|
@ -14,6 +14,7 @@ import '../base/context.dart';
|
|||||||
import '../base/process.dart';
|
import '../base/process.dart';
|
||||||
import '../build_configuration.dart';
|
import '../build_configuration.dart';
|
||||||
import '../device.dart';
|
import '../device.dart';
|
||||||
|
import '../flx.dart' as flx;
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../toolchain.dart';
|
import '../toolchain.dart';
|
||||||
import 'mac.dart';
|
import 'mac.dart';
|
||||||
@ -314,12 +315,69 @@ class IOSSimulator extends Device {
|
|||||||
int debugPort: observatoryDefaultPort,
|
int debugPort: observatoryDefaultPort,
|
||||||
Map<String, dynamic> platformArgs
|
Map<String, dynamic> platformArgs
|
||||||
}) async {
|
}) async {
|
||||||
// TODO(chinmaygarde): Use mainPath, route.
|
|
||||||
printTrace('Building ${app.name} for $id.');
|
printTrace('Building ${app.name} for $id.');
|
||||||
|
|
||||||
if (clearLogs)
|
if (clearLogs)
|
||||||
this.clearLogs();
|
this.clearLogs();
|
||||||
|
|
||||||
|
if(!(await _setupUpdatedApplicationBundle(app, toolchain)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Prepare launch arguments.
|
||||||
|
List<String> args = <String>[
|
||||||
|
"--flx=${path.absolute(path.join('build', 'app.flx'))}",
|
||||||
|
"--dart-main=${path.absolute(mainPath)}",
|
||||||
|
"--package-root=${path.absolute('packages')}",
|
||||||
|
];
|
||||||
|
|
||||||
|
if (checked)
|
||||||
|
args.add("--enable-checked-mode");
|
||||||
|
|
||||||
|
if (startPaused)
|
||||||
|
args.add("--start-paused");
|
||||||
|
|
||||||
|
if (debugPort != observatoryDefaultPort)
|
||||||
|
args.add("--observatory-port=$debugPort");
|
||||||
|
|
||||||
|
// Launch the updated application in the simulator.
|
||||||
|
try {
|
||||||
|
SimControl.instance.launch(id, app.id, args);
|
||||||
|
} catch (error) {
|
||||||
|
printError('$error');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
printTrace('Successfully started ${app.name} on $id.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _applicationIsInstalledAndRunning(ApplicationPackage app) {
|
||||||
|
bool isInstalled = exitsHappy([
|
||||||
|
'xcrun',
|
||||||
|
'simctl',
|
||||||
|
'get_app_container',
|
||||||
|
'booted',
|
||||||
|
app.id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
bool isRunning = exitsHappy([
|
||||||
|
'/usr/bin/killall',
|
||||||
|
'Runner',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return isInstalled && isRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _setupUpdatedApplicationBundle(ApplicationPackage app, Toolchain toolchain) async {
|
||||||
|
if (_applicationIsInstalledAndRunning(app)) {
|
||||||
|
return _sideloadUpdatedAssetsForInstalledApplicationBundle(app, toolchain);
|
||||||
|
} else {
|
||||||
|
return _buildAndInstallApplicationBundle(app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _buildAndInstallApplicationBundle(ApplicationPackage app) async {
|
||||||
// Step 1: Build the Xcode project.
|
// Step 1: Build the Xcode project.
|
||||||
bool buildResult = await buildIOSXcodeProject(app, buildForDevice: false);
|
bool buildResult = await buildIOSXcodeProject(app, buildForDevice: false);
|
||||||
if (!buildResult) {
|
if (!buildResult) {
|
||||||
@ -337,32 +395,14 @@ class IOSSimulator extends Device {
|
|||||||
|
|
||||||
// Step 3: Install the updated bundle to the simulator.
|
// Step 3: Install the updated bundle to the simulator.
|
||||||
SimControl.instance.install(id, path.absolute(bundle.path));
|
SimControl.instance.install(id, path.absolute(bundle.path));
|
||||||
|
|
||||||
// Step 4: Prepare launch arguments.
|
|
||||||
List<String> args = <String>[];
|
|
||||||
|
|
||||||
if (checked)
|
|
||||||
args.add("--enable-checked-mode");
|
|
||||||
|
|
||||||
if (startPaused)
|
|
||||||
args.add("--start-paused");
|
|
||||||
|
|
||||||
if (debugPort != observatoryDefaultPort)
|
|
||||||
args.add("--observatory-port=$debugPort");
|
|
||||||
|
|
||||||
// Step 5: Launch the updated application in the simulator.
|
|
||||||
try {
|
|
||||||
SimControl.instance.launch(id, app.id, args);
|
|
||||||
} catch (error) {
|
|
||||||
printError('$error');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
printTrace('Successfully started ${app.name} on $id.');
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> _sideloadUpdatedAssetsForInstalledApplicationBundle(
|
||||||
|
ApplicationPackage app, Toolchain toolchain) async {
|
||||||
|
return (await flx.build(toolchain, precompiledSnapshot: true)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> stopApp(ApplicationPackage app) async {
|
Future<bool> stopApp(ApplicationPackage app) async {
|
||||||
// Currently we don't have a way to stop an app running on iOS.
|
// Currently we don't have a way to stop an app running on iOS.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user