Add: flutter build ios [--[no-]simulator]
This allows the user to build an iOS application bundle from the command line even if no device is attached to the workstation.
This commit is contained in:
@@ -8,12 +8,14 @@ import 'dart:io';
|
||||
import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import 'build_apk.dart';
|
||||
import 'build_ios.dart';
|
||||
import 'build_flx.dart';
|
||||
|
||||
class BuildCommand extends FlutterCommand {
|
||||
BuildCommand() {
|
||||
addSubcommand(new BuildApkCommand());
|
||||
addSubcommand(new BuildCleanCommand());
|
||||
addSubcommand(new BuildIOSCommand());
|
||||
addSubcommand(new BuildFlxCommand());
|
||||
}
|
||||
|
||||
|
||||
62
packages/flutter_tools/lib/src/commands/build_ios.dart
Normal file
62
packages/flutter_tools/lib/src/commands/build_ios.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../globals.dart';
|
||||
import '../ios/mac.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class BuildIOSCommand extends FlutterCommand {
|
||||
BuildIOSCommand() {
|
||||
argParser.addFlag('simulator', help: 'Build for the iOS simulator instead of the device');
|
||||
}
|
||||
|
||||
@override
|
||||
final String name = 'ios';
|
||||
|
||||
@override
|
||||
final String description = 'Build an iOS application bundle.';
|
||||
|
||||
@override
|
||||
Future<int> runInProject() async {
|
||||
if (getCurrentHostPlatform() != HostPlatform.mac) {
|
||||
printError('Building for iOS is only supported on the Mac.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
printTrace('Ensuring toolchains are up to date.');
|
||||
|
||||
await Future.wait([
|
||||
downloadToolchain(),
|
||||
downloadApplicationPackages(),
|
||||
], eagerError: true);
|
||||
|
||||
IOSApp app = applicationPackages.iOS;
|
||||
|
||||
if (app == null) {
|
||||
printError('Application not configured for iOS');
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool forSimulator = argResults['simulator'];
|
||||
|
||||
String logTarget = forSimulator ? "simulator" : "device";
|
||||
|
||||
printStatus('Building the application for $logTarget.');
|
||||
|
||||
bool result = await buildIOSXcodeProject(app, buildForDevice: !forSimulator);
|
||||
|
||||
if (!result) {
|
||||
printError('Encountered error while building for $logTarget.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
printStatus('Done.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user