parent
bc5d407477
commit
612a097d1f
@ -49,6 +49,7 @@ BuildApp() {
|
||||
|
||||
RunCommand ${FLUTTER_ROOT}/bin/flutter --suppress-analytics build aot \
|
||||
--target-platform=ios \
|
||||
--target=${FLUTTER_TARGET} \
|
||||
--release \
|
||||
${interpreter_flag} \
|
||||
${local_engine_flag}
|
||||
@ -69,6 +70,7 @@ BuildApp() {
|
||||
fi
|
||||
|
||||
RunCommand ${FLUTTER_ROOT}/bin/flutter --suppress-analytics build flx \
|
||||
--target=${FLUTTER_TARGET} \
|
||||
--output-file=${derived_dir}/app.flx \
|
||||
${precompilation_flag} \
|
||||
${local_engine_flag} \
|
||||
|
@ -15,6 +15,7 @@ import '../runner/flutter_command.dart';
|
||||
|
||||
class BuildIOSCommand extends FlutterCommand {
|
||||
BuildIOSCommand() {
|
||||
usesTargetOption();
|
||||
addBuildModeFlags();
|
||||
argParser.addFlag('simulator', help: 'Build for the iOS simulator instead of the device.');
|
||||
argParser.addFlag('codesign', negatable: true, defaultsTo: true,
|
||||
@ -53,9 +54,13 @@ class BuildIOSCommand extends FlutterCommand {
|
||||
|
||||
String typeName = path.basename(tools.getEngineArtifactsDirectory(TargetPlatform.ios, getBuildMode()).path);
|
||||
Status status = logger.startProgress('Building $app for $logTarget ($typeName)...');
|
||||
XcodeBuildResult result = await buildXcodeProject(app, getBuildMode(),
|
||||
buildForDevice: !forSimulator,
|
||||
codesign: shouldCodesign);
|
||||
XcodeBuildResult result = await buildXcodeProject(
|
||||
app: app,
|
||||
mode: getBuildMode(),
|
||||
target: argResults['target'],
|
||||
buildForDevice: !forSimulator,
|
||||
codesign: shouldCodesign
|
||||
);
|
||||
status.stop(showElapsedTime: true);
|
||||
|
||||
if (!result.success) {
|
||||
|
@ -180,7 +180,7 @@ class IOSDevice extends Device {
|
||||
printTrace('Building ${app.name} for $id');
|
||||
|
||||
// Step 1: Install the precompiled/DBC application if necessary.
|
||||
XcodeBuildResult buildResult = await buildXcodeProject(app, mode, buildForDevice: true);
|
||||
XcodeBuildResult buildResult = await buildXcodeProject(app: app, mode: mode, buildForDevice: true);
|
||||
if (!buildResult.success) {
|
||||
printError('Could not build the precompiled application for the device.');
|
||||
return new LaunchResult.failed();
|
||||
|
@ -13,6 +13,7 @@ import '../base/context.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_info.dart';
|
||||
import '../cache.dart';
|
||||
import '../flx.dart' as flx;
|
||||
import '../globals.dart';
|
||||
import '../services.dart';
|
||||
import 'setup_xcodeproj.dart';
|
||||
@ -97,18 +98,23 @@ bool _xcodeVersionCheckValid(int major, int minor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<XcodeBuildResult> buildXcodeProject(ApplicationPackage app, BuildMode mode,
|
||||
{ bool buildForDevice, bool codesign: true }) async {
|
||||
Future<XcodeBuildResult> buildXcodeProject({
|
||||
ApplicationPackage app,
|
||||
BuildMode mode,
|
||||
String target: flx.defaultMainPath,
|
||||
bool buildForDevice,
|
||||
bool codesign: true
|
||||
}) async {
|
||||
String flutterProjectPath = Directory.current.path;
|
||||
|
||||
if (xcodeProjectRequiresUpdate(mode)) {
|
||||
printTrace('Initializing the Xcode project.');
|
||||
if ((await setupXcodeProjectHarness(flutterProjectPath, mode)) != 0) {
|
||||
if ((await setupXcodeProjectHarness(flutterProjectPath, mode, target)) != 0) {
|
||||
printError('Could not initialize the Xcode project.');
|
||||
return new XcodeBuildResult(false);
|
||||
}
|
||||
} else {
|
||||
updateXcodeGeneratedProperties(flutterProjectPath, mode);
|
||||
updateXcodeGeneratedProperties(flutterProjectPath, mode, target);
|
||||
}
|
||||
|
||||
if (!_validateEngineRevision(app))
|
||||
|
@ -54,7 +54,7 @@ bool _inflateXcodeArchive(String directory, List<int> archiveBytes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void updateXcodeGeneratedProperties(String projectPath, BuildMode mode) {
|
||||
void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String target) {
|
||||
StringBuffer localsBuffer = new StringBuffer();
|
||||
|
||||
localsBuffer.writeln('// This is a generated file; do not edit or check into version control.');
|
||||
@ -66,6 +66,9 @@ void updateXcodeGeneratedProperties(String projectPath, BuildMode mode) {
|
||||
String applicationRoot = path.normalize(Directory.current.path);
|
||||
localsBuffer.writeln('FLUTTER_APPLICATION_PATH=$applicationRoot');
|
||||
|
||||
// Relative to FLUTTER_APPLICATION_PATH, which is [Directory.current].
|
||||
localsBuffer.writeln('FLUTTER_TARGET=$target');
|
||||
|
||||
String flutterFrameworkDir = path.normalize(tools.getEngineArtifactsDirectory(TargetPlatform.ios, mode).path);
|
||||
localsBuffer.writeln('FLUTTER_FRAMEWORK_DIR=$flutterFrameworkDir');
|
||||
|
||||
@ -97,7 +100,7 @@ bool xcodeProjectRequiresUpdate(BuildMode mode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<int> setupXcodeProjectHarness(String flutterProjectPath, BuildMode mode) async {
|
||||
Future<int> setupXcodeProjectHarness(String flutterProjectPath, BuildMode mode, String target) async {
|
||||
// Step 1: Fetch the archive from the cloud
|
||||
String iosFilesPath = path.join(flutterProjectPath, 'ios');
|
||||
String xcodeprojPath = path.join(iosFilesPath, '.generated');
|
||||
@ -119,7 +122,7 @@ Future<int> setupXcodeProjectHarness(String flutterProjectPath, BuildMode mode)
|
||||
}
|
||||
|
||||
// Step 3: Populate the Generated.xcconfig with project specific paths
|
||||
updateXcodeGeneratedProperties(flutterProjectPath, mode);
|
||||
updateXcodeGeneratedProperties(flutterProjectPath, mode, target);
|
||||
|
||||
// Step 4: Write the REVISION file
|
||||
File revisionFile = new File(path.join(xcodeprojPath, 'REVISION'));
|
||||
|
@ -548,7 +548,7 @@ class IOSSimulator extends Device {
|
||||
Future<bool> _buildAndInstallApplicationBundle(ApplicationPackage app) async {
|
||||
// Step 1: Build the Xcode project.
|
||||
// The build mode for the simulator is always debug.
|
||||
XcodeBuildResult buildResult = await buildXcodeProject(app, BuildMode.debug, buildForDevice: false);
|
||||
XcodeBuildResult buildResult = await buildXcodeProject(app: app, mode: BuildMode.debug, buildForDevice: false);
|
||||
if (!buildResult.success) {
|
||||
printError('Could not build the application for the simulator.');
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user