Commit 66e10061 authored by Chinmay Garde's avatar Chinmay Garde

Xcodebuild takes an extra parameter for the build directory.

parent 3f9dcfe1
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import '../application_package.dart'; import '../application_package.dart';
import '../build_configuration.dart'; import '../build_configuration.dart';
...@@ -10,6 +11,8 @@ import '../globals.dart'; ...@@ -10,6 +11,8 @@ import '../globals.dart';
import '../ios/mac.dart'; import '../ios/mac.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import 'package:path/path.dart' as path;
class BuildIOSCommand extends FlutterCommand { class BuildIOSCommand extends FlutterCommand {
BuildIOSCommand() { BuildIOSCommand() {
argParser.addFlag('simulator', help: 'Build for the iOS simulator instead of the device'); argParser.addFlag('simulator', help: 'Build for the iOS simulator instead of the device');
...@@ -19,7 +22,7 @@ class BuildIOSCommand extends FlutterCommand { ...@@ -19,7 +22,7 @@ class BuildIOSCommand extends FlutterCommand {
final String name = 'ios'; final String name = 'ios';
@override @override
final String description = 'Build an iOS application bundle.'; final String description = 'Build an iOS application bundle (Mac OSX host only).';
@override @override
Future<int> runInProject() async { Future<int> runInProject() async {
...@@ -48,14 +51,20 @@ class BuildIOSCommand extends FlutterCommand { ...@@ -48,14 +51,20 @@ class BuildIOSCommand extends FlutterCommand {
printStatus('Building the application for $logTarget.'); printStatus('Building the application for $logTarget.');
bool result = await buildIOSXcodeProject(app, buildForDevice: !forSimulator); Directory buildDir = new Directory(path.join('build', 'ios_$logTarget'));
if (!buildDir.existsSync())
await buildDir.create();
bool result = await buildIOSXcodeProject(app,
buildForDevice: !forSimulator, buildDirectory: buildDir);
if (!result) { if (!result) {
printError('Encountered error while building for $logTarget.'); printError('Encountered error while building for $logTarget.');
return 1; return 1;
} }
printStatus('Done.'); printStatus('Built in ${buildDir.path}.');
return 0; return 0;
} }
......
...@@ -89,7 +89,8 @@ bool _xcodeVersionCheckValid(int major, int minor) { ...@@ -89,7 +89,8 @@ bool _xcodeVersionCheckValid(int major, int minor) {
return false; return false;
} }
Future<bool> buildIOSXcodeProject(ApplicationPackage app, { bool buildForDevice }) async { Future<bool> buildIOSXcodeProject(ApplicationPackage app,
{ bool buildForDevice, Directory buildDirectory }) async {
String flutterProjectPath = Directory.current.path; String flutterProjectPath = Directory.current.path;
if (xcodeProjectRequiresUpdate()) { if (xcodeProjectRequiresUpdate()) {
...@@ -114,9 +115,23 @@ Future<bool> buildIOSXcodeProject(ApplicationPackage app, { bool buildForDevice ...@@ -114,9 +115,23 @@ Future<bool> buildIOSXcodeProject(ApplicationPackage app, { bool buildForDevice
await _addServicesToBundle(new Directory(app.localPath)); await _addServicesToBundle(new Directory(app.localPath));
List<String> commands = <String>[ List<String> commands = <String>[
'/usr/bin/env', 'xcrun', 'xcodebuild', '-target', 'Runner', '-configuration', 'Release' '/usr/bin/env',
'xcrun',
'xcodebuild',
'-target', 'Runner',
'-configuration', 'Release',
'ONLY_ACTIVE_ARCH=YES',
]; ];
if (buildDirectory != null) {
if (!buildDirectory.existsSync()) {
printError('The specified build directory ${buildDirectory.path} does not exist');
return false;
}
commands.add('TARGET_BUILD_DIR=${buildDirectory.absolute.path}');
}
if (buildForDevice) { if (buildForDevice) {
commands.addAll(<String>['-sdk', 'iphoneos', '-arch', 'arm64']); commands.addAll(<String>['-sdk', 'iphoneos', '-arch', 'arm64']);
} else { } else {
......
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