Turn off bitcode in existing iOS Xcode projects (#112828)

This commit is contained in:
Jenn Magder
2022-10-03 18:15:24 -07:00
committed by GitHub
parent c77e4cdd34
commit 8c0aa6c66c
3 changed files with 114 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ import 'migrations/host_app_info_plist_migration.dart';
import 'migrations/ios_deployment_target_migration.dart';
import 'migrations/project_base_configuration_migration.dart';
import 'migrations/project_build_location_migration.dart';
import 'migrations/remove_bitcode_migration.dart';
import 'migrations/remove_framework_link_and_embedding_migration.dart';
import 'migrations/xcode_build_system_migration.dart';
import 'xcode_build_settings.dart';
@@ -128,6 +129,7 @@ Future<XcodeBuildResult> buildXcodeProject({
XcodeProjectObjectVersionMigration(app.project, globals.logger),
HostAppInfoPlistMigration(app.project, globals.logger),
XcodeScriptBuildPhaseMigration(app.project, globals.logger),
RemoveBitcodeMigration(app.project, globals.logger),
];
final ProjectMigration migration = ProjectMigration(migrators);

View File

@@ -0,0 +1,41 @@
// Copyright 2014 The Flutter 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 '../../base/file_system.dart';
import '../../base/project_migrator.dart';
import '../../xcode_project.dart';
/// Remove deprecated bitcode build setting.
class RemoveBitcodeMigration extends ProjectMigrator {
RemoveBitcodeMigration(
IosProject project,
super.logger,
) : _xcodeProjectInfoFile = project.xcodeProjectInfoFile;
final File _xcodeProjectInfoFile;
@override
bool migrate() {
if (_xcodeProjectInfoFile.existsSync()) {
processFileLines(_xcodeProjectInfoFile);
} else {
logger.printTrace('Xcode project not found, skipping removing bitcode migration.');
}
return true;
}
@override
String? migrateLine(String line) {
if (line.contains('ENABLE_BITCODE = YES;')) {
if (!migrationRequired) {
// Only print for the first discovered change found.
logger.printWarning('Disabling deprecated bitcode Xcode build setting. See https://github.com/flutter/flutter/issues/107887 for additional details.');
}
return line.replaceAll('ENABLE_BITCODE = YES', 'ENABLE_BITCODE = NO');
}
return line;
}
}