Build iOS apps using Swift Packages (#58522)
This commit is contained in:
@@ -26,6 +26,7 @@ import '../reporting/reporting.dart';
|
||||
import 'code_signing.dart';
|
||||
import 'migrations/ios_migrator.dart';
|
||||
import 'migrations/project_base_configuration_migration.dart';
|
||||
import 'migrations/project_build_location_migration.dart';
|
||||
import 'migrations/remove_framework_link_and_embedding_migration.dart';
|
||||
import 'migrations/xcode_build_system_migration.dart';
|
||||
import 'xcodeproj.dart';
|
||||
@@ -97,6 +98,7 @@ Future<XcodeBuildResult> buildXcodeProject({
|
||||
RemoveFrameworkLinkAndEmbeddingMigration(app.project, globals.logger, globals.xcode, globals.flutterUsage),
|
||||
XcodeBuildSystemMigration(app.project, globals.logger),
|
||||
ProjectBaseConfigurationMigration(app.project, globals.logger),
|
||||
ProjectBuildLocationMigration(app.project, globals.logger),
|
||||
];
|
||||
|
||||
final IOSMigration migration = IOSMigration(migrators);
|
||||
|
||||
@@ -84,7 +84,7 @@ class ProjectBaseConfigurationMigration extends IOSMigrator {
|
||||
newProjectContents = newProjectContents.replaceAll(releaseBaseConfigurationOriginal, releaseBaseConfigurationReplacement);
|
||||
if (originalProjectContents != newProjectContents) {
|
||||
logger.printStatus('Project base configurations detected, removing.');
|
||||
_xcodeProjectInfoFile.writeAsStringSync(newProjectContents.toString());
|
||||
_xcodeProjectInfoFile.writeAsStringSync(newProjectContents);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// 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/logger.dart';
|
||||
import '../../project.dart';
|
||||
import 'ios_migrator.dart';
|
||||
|
||||
// Update the xcodeproj build location. Legacy build location does not work with Swift Packages.
|
||||
class ProjectBuildLocationMigration extends IOSMigrator {
|
||||
ProjectBuildLocationMigration(
|
||||
IosProject project,
|
||||
Logger logger,
|
||||
) : _xcodeProjectWorkspaceData = project.xcodeProjectWorkspaceData,
|
||||
super(logger);
|
||||
|
||||
final File _xcodeProjectWorkspaceData;
|
||||
|
||||
@override
|
||||
bool migrate() {
|
||||
if (!_xcodeProjectWorkspaceData.existsSync()) {
|
||||
logger.printTrace('Xcode project workspace data not found, skipping build location migration.');
|
||||
return true;
|
||||
}
|
||||
|
||||
processFileLines(_xcodeProjectWorkspaceData);
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
String migrateLine(String line) {
|
||||
const String legacyBuildLocation = 'location = "group:';
|
||||
const String defaultBuildLocation = 'location = "self:';
|
||||
|
||||
return line.replaceAll(legacyBuildLocation, defaultBuildLocation);
|
||||
}
|
||||
}
|
||||
@@ -398,6 +398,11 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
|
||||
@override
|
||||
File get xcodeProjectInfoFile => xcodeProject.childFile('project.pbxproj');
|
||||
|
||||
File get xcodeProjectWorkspaceData =>
|
||||
xcodeProject
|
||||
.childDirectory('project.xcworkspace')
|
||||
.childFile('contents.xcworkspacedata');
|
||||
|
||||
@override
|
||||
Directory get xcodeWorkspace => hostAppRoot.childDirectory('$_hostAppProjectName.xcworkspace');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user