Build iOS apps using Swift Packages (#59009)
This commit is contained in:
parent
0c8da86fbe
commit
43e28084fc
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -12,7 +12,7 @@ import 'package:path/path.dart' as path;
|
|||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
await task(() async {
|
await task(() async {
|
||||||
section('Copy test Flutter App with WatchOS Companion');
|
section('Copy app with watchOS companion and Swift Package');
|
||||||
|
|
||||||
String watchDeviceID;
|
String watchDeviceID;
|
||||||
String phoneDeviceID;
|
String phoneDeviceID;
|
||||||
@ -47,7 +47,7 @@ Future<void> main() async {
|
|||||||
|
|
||||||
if (!appReleaseBuilt) {
|
if (!appReleaseBuilt) {
|
||||||
return TaskResult.failure(
|
return TaskResult.failure(
|
||||||
'Failed to build flutter iOS app with WatchOS companion in release mode.');
|
'Failed to build flutter iOS app with watchOS companion and Swift Package in release mode.');
|
||||||
}
|
}
|
||||||
|
|
||||||
section('Create debug build');
|
section('Create debug build');
|
||||||
@ -69,7 +69,7 @@ Future<void> main() async {
|
|||||||
|
|
||||||
if (!appDebugBuilt) {
|
if (!appDebugBuilt) {
|
||||||
return TaskResult.failure(
|
return TaskResult.failure(
|
||||||
'Failed to build flutter iOS app with WatchOS companion in debug mode.');
|
'Failed to build flutter iOS app with watchOS companion and Swift Package in debug mode.');
|
||||||
}
|
}
|
||||||
|
|
||||||
section('Create build for a simulator device');
|
section('Create build for a simulator device');
|
||||||
@ -183,7 +183,7 @@ Future<void> main() async {
|
|||||||
|
|
||||||
if (!appSimulatorBuilt) {
|
if (!appSimulatorBuilt) {
|
||||||
return TaskResult.failure(
|
return TaskResult.failure(
|
||||||
'Failed to build flutter iOS app with WatchOS companion in debug mode for simulated device.');
|
'Failed to build flutter iOS app with watchOS companion and Swift Package in debug mode for simulated device.');
|
||||||
}
|
}
|
||||||
|
|
||||||
section('Run app on simulator device');
|
section('Run app on simulator device');
|
||||||
@ -229,7 +229,7 @@ Future<void> main() async {
|
|||||||
|
|
||||||
if (exitCode != 0)
|
if (exitCode != 0)
|
||||||
return TaskResult.failure(
|
return TaskResult.failure(
|
||||||
'Failed to start flutter iOS app with WatchOS companion on simulated device.');
|
'Failed to start flutter iOS app with watchOS companion and Swift Package on simulated device.');
|
||||||
|
|
||||||
return TaskResult.success(null);
|
return TaskResult.success(null);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -262,9 +262,14 @@
|
|||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
|
||||||
|
"${PODS_ROOT}/../Flutter/Flutter.framework",
|
||||||
|
"${BUILT_PRODUCTS_DIR}/device_info/device_info.framework",
|
||||||
);
|
);
|
||||||
name = "[CP] Embed Pods Frameworks";
|
name = "[CP] Embed Pods Frameworks";
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
|
||||||
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework",
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -3,3 +3,4 @@
|
|||||||
Integration test to test building an iOS app with
|
Integration test to test building an iOS app with
|
||||||
non-Flutter features:
|
non-Flutter features:
|
||||||
- watchOS app and extension
|
- watchOS app and extension
|
||||||
|
- Swift Package
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 50;
|
objectVersion = 52;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
@ -22,6 +22,7 @@
|
|||||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||||
|
F735C5C42485E50A002BE868 /* PlayingCard in Frameworks */ = {isa = PBXBuildFile; productRef = F735C5C32485E50A002BE868 /* PlayingCard */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -115,6 +116,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
F735C5C42485E50A002BE868 /* PlayingCard in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -262,6 +264,9 @@
|
|||||||
49C15B68243E340F0025F804 /* PBXTargetDependency */,
|
49C15B68243E340F0025F804 /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
name = Runner;
|
name = Runner;
|
||||||
|
packageProductDependencies = (
|
||||||
|
F735C5C32485E50A002BE868 /* PlayingCard */,
|
||||||
|
);
|
||||||
productName = Runner;
|
productName = Runner;
|
||||||
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
|
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
@ -297,6 +302,9 @@
|
|||||||
Base,
|
Base,
|
||||||
);
|
);
|
||||||
mainGroup = 97C146E51CF9000F007C117D;
|
mainGroup = 97C146E51CF9000F007C117D;
|
||||||
|
packageReferences = (
|
||||||
|
F735C5C22485E50A002BE868 /* XCRemoteSwiftPackageReference "example-package-playingcard" */,
|
||||||
|
);
|
||||||
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
|
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
@ -907,6 +915,25 @@
|
|||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
|
F735C5C22485E50A002BE868 /* XCRemoteSwiftPackageReference "example-package-playingcard" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://github.com/apple/example-package-playingcard.git";
|
||||||
|
requirement = {
|
||||||
|
kind = upToNextMajorVersion;
|
||||||
|
minimumVersion = 3.0.5;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
F735C5C32485E50A002BE868 /* PlayingCard */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = F735C5C22485E50A002BE868 /* XCRemoteSwiftPackageReference "example-package-playingcard" */;
|
||||||
|
productName = PlayingCard;
|
||||||
|
};
|
||||||
|
/* End XCSwiftPackageProductDependency section */
|
||||||
};
|
};
|
||||||
rootObject = 97C146E61CF9000F007C117D /* Project object */;
|
rootObject = 97C146E61CF9000F007C117D /* Project object */;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"object": {
|
||||||
|
"pins": [
|
||||||
|
{
|
||||||
|
"package": "PlayingCard",
|
||||||
|
"repositoryURL": "https://github.com/apple/example-package-playingcard.git",
|
||||||
|
"state": {
|
||||||
|
"branch": null,
|
||||||
|
"revision": "39ddabb01e8102ab548a8c6bb3eb20b15f3b4fbc",
|
||||||
|
"version": "3.0.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"version": 1
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"object": {
|
||||||
|
"pins": [
|
||||||
|
{
|
||||||
|
"package": "PlayingCard",
|
||||||
|
"repositoryURL": "https://github.com/apple/example-package-playingcard.git",
|
||||||
|
"state": {
|
||||||
|
"branch": null,
|
||||||
|
"revision": "39ddabb01e8102ab548a8c6bb3eb20b15f3b4fbc",
|
||||||
|
"version": "3.0.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"version": 1
|
||||||
|
}
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
|
||||||
<FileRef
|
|
||||||
location = "group:Pods/Pods.xcodeproj">
|
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
|
||||||
<FileRef
|
|
||||||
location = "group:Pods/Pods.xcodeproj">
|
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
|
||||||
<FileRef
|
|
||||||
location = "group:Pods/Pods.xcodeproj">
|
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -26,6 +26,7 @@ import '../reporting/reporting.dart';
|
|||||||
import 'code_signing.dart';
|
import 'code_signing.dart';
|
||||||
import 'migrations/ios_migrator.dart';
|
import 'migrations/ios_migrator.dart';
|
||||||
import 'migrations/project_base_configuration_migration.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/remove_framework_link_and_embedding_migration.dart';
|
||||||
import 'migrations/xcode_build_system_migration.dart';
|
import 'migrations/xcode_build_system_migration.dart';
|
||||||
import 'xcodeproj.dart';
|
import 'xcodeproj.dart';
|
||||||
@ -97,6 +98,7 @@ Future<XcodeBuildResult> buildXcodeProject({
|
|||||||
RemoveFrameworkLinkAndEmbeddingMigration(app.project, globals.logger, globals.xcode, globals.flutterUsage),
|
RemoveFrameworkLinkAndEmbeddingMigration(app.project, globals.logger, globals.xcode, globals.flutterUsage),
|
||||||
XcodeBuildSystemMigration(app.project, globals.logger),
|
XcodeBuildSystemMigration(app.project, globals.logger),
|
||||||
ProjectBaseConfigurationMigration(app.project, globals.logger),
|
ProjectBaseConfigurationMigration(app.project, globals.logger),
|
||||||
|
ProjectBuildLocationMigration(app.project, globals.logger),
|
||||||
];
|
];
|
||||||
|
|
||||||
final IOSMigration migration = IOSMigration(migrators);
|
final IOSMigration migration = IOSMigration(migrators);
|
||||||
|
@ -26,6 +26,13 @@ abstract class IOSMigrator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
|
String migrateFileContents(String fileContents) {
|
||||||
|
return fileContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
/// Calls [migrateLine] per line, then [migrateFileContents]
|
||||||
|
/// including the line migrations.
|
||||||
void processFileLines(File file) {
|
void processFileLines(File file) {
|
||||||
final List<String> lines = file.readAsLinesSync();
|
final List<String> lines = file.readAsLinesSync();
|
||||||
|
|
||||||
@ -51,9 +58,16 @@ abstract class IOSMigrator {
|
|||||||
newProjectContents.writeln(newProjectLine);
|
newProjectContents.writeln(newProjectLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String projectContentsWithMigratedLines = newProjectContents.toString();
|
||||||
|
final String projectContentsWithMigratedContents = migrateFileContents(projectContentsWithMigratedLines);
|
||||||
|
if (projectContentsWithMigratedLines != projectContentsWithMigratedContents) {
|
||||||
|
logger.printTrace('Migrating $basename contents');
|
||||||
|
migrationRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (migrationRequired) {
|
if (migrationRequired) {
|
||||||
logger.printStatus('Upgrading $basename');
|
logger.printStatus('Upgrading $basename');
|
||||||
file.writeAsStringSync(newProjectContents.toString());
|
file.writeAsStringSync(projectContentsWithMigratedContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
// 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:Runner.xcodeproj"';
|
||||||
|
const String defaultBuildLocation = 'location = "self:"';
|
||||||
|
|
||||||
|
return line.replaceAll(legacyBuildLocation, defaultBuildLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String migrateFileContents(String fileContents) {
|
||||||
|
const String podLocation = '''
|
||||||
|
<FileRef
|
||||||
|
location = "group:Pods/Pods.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
''';
|
||||||
|
|
||||||
|
return fileContents.replaceAll(podLocation, '');
|
||||||
|
}
|
||||||
|
}
|
@ -398,6 +398,11 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
|
|||||||
@override
|
@override
|
||||||
File get xcodeProjectInfoFile => xcodeProject.childFile('project.pbxproj');
|
File get xcodeProjectInfoFile => xcodeProject.childFile('project.pbxproj');
|
||||||
|
|
||||||
|
File get xcodeProjectWorkspaceData =>
|
||||||
|
xcodeProject
|
||||||
|
.childDirectory('project.xcworkspace')
|
||||||
|
.childFile('contents.xcworkspacedata');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Directory get xcodeWorkspace => hostAppRoot.childDirectory('$_hostAppProjectName.xcworkspace');
|
Directory get xcodeWorkspace => hostAppRoot.childDirectory('$_hostAppProjectName.xcworkspace');
|
||||||
|
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
@ -5,10 +5,9 @@
|
|||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_tools/src/base/logger.dart';
|
import 'package:flutter_tools/src/base/logger.dart';
|
||||||
import 'package:flutter_tools/src/base/platform.dart';
|
|
||||||
import 'package:flutter_tools/src/base/terminal.dart';
|
|
||||||
import 'package:flutter_tools/src/ios/migrations/ios_migrator.dart';
|
import 'package:flutter_tools/src/ios/migrations/ios_migrator.dart';
|
||||||
import 'package:flutter_tools/src/ios/migrations/project_base_configuration_migration.dart';
|
import 'package:flutter_tools/src/ios/migrations/project_base_configuration_migration.dart';
|
||||||
|
import 'package:flutter_tools/src/ios/migrations/project_build_location_migration.dart';
|
||||||
import 'package:flutter_tools/src/ios/migrations/remove_framework_link_and_embedding_migration.dart';
|
import 'package:flutter_tools/src/ios/migrations/remove_framework_link_and_embedding_migration.dart';
|
||||||
import 'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.dart';
|
import 'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.dart';
|
||||||
import 'package:flutter_tools/src/macos/xcode.dart';
|
import 'package:flutter_tools/src/macos/xcode.dart';
|
||||||
@ -49,15 +48,7 @@ void main () {
|
|||||||
memoryFileSystem = MemoryFileSystem();
|
memoryFileSystem = MemoryFileSystem();
|
||||||
mockXcode = MockXcode();
|
mockXcode = MockXcode();
|
||||||
xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj');
|
xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj');
|
||||||
|
testLogger = BufferLogger.test();
|
||||||
testLogger = BufferLogger(
|
|
||||||
terminal: AnsiTerminal(
|
|
||||||
stdio: null,
|
|
||||||
platform: const LocalPlatform(),
|
|
||||||
),
|
|
||||||
outputPreferences: OutputPreferences.test(),
|
|
||||||
);
|
|
||||||
|
|
||||||
mockIosProject = MockIosProject();
|
mockIosProject = MockIosProject();
|
||||||
when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile);
|
when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile);
|
||||||
});
|
});
|
||||||
@ -268,15 +259,7 @@ keep this 2
|
|||||||
setUp(() {
|
setUp(() {
|
||||||
memoryFileSystem = MemoryFileSystem();
|
memoryFileSystem = MemoryFileSystem();
|
||||||
xcodeWorkspaceSharedSettings = memoryFileSystem.file('WorkspaceSettings.xcsettings');
|
xcodeWorkspaceSharedSettings = memoryFileSystem.file('WorkspaceSettings.xcsettings');
|
||||||
|
testLogger = BufferLogger.test();
|
||||||
testLogger = BufferLogger(
|
|
||||||
terminal: AnsiTerminal(
|
|
||||||
stdio: null,
|
|
||||||
platform: const LocalPlatform(),
|
|
||||||
),
|
|
||||||
outputPreferences: OutputPreferences.test(),
|
|
||||||
);
|
|
||||||
|
|
||||||
mockIosProject = MockIosProject();
|
mockIosProject = MockIosProject();
|
||||||
when(mockIosProject.xcodeWorkspaceSharedSettings).thenReturn(xcodeWorkspaceSharedSettings);
|
when(mockIosProject.xcodeWorkspaceSharedSettings).thenReturn(xcodeWorkspaceSharedSettings);
|
||||||
});
|
});
|
||||||
@ -339,6 +322,86 @@ keep this 2
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('Xcode default build location', () {
|
||||||
|
MemoryFileSystem memoryFileSystem;
|
||||||
|
BufferLogger testLogger;
|
||||||
|
MockIosProject mockIosProject;
|
||||||
|
File xcodeProjectWorkspaceData;
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
memoryFileSystem = MemoryFileSystem();
|
||||||
|
xcodeProjectWorkspaceData = memoryFileSystem.file('contents.xcworkspacedata');
|
||||||
|
testLogger = BufferLogger.test();
|
||||||
|
mockIosProject = MockIosProject();
|
||||||
|
when(mockIosProject.xcodeProjectWorkspaceData).thenReturn(xcodeProjectWorkspaceData);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('skipped if files are missing', () {
|
||||||
|
final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration(
|
||||||
|
mockIosProject,
|
||||||
|
testLogger,
|
||||||
|
);
|
||||||
|
expect(iosProjectMigration.migrate(), isTrue);
|
||||||
|
expect(xcodeProjectWorkspaceData.existsSync(), isFalse);
|
||||||
|
|
||||||
|
expect(testLogger.traceText, contains('Xcode project workspace data not found, skipping build location migration.'));
|
||||||
|
expect(testLogger.statusText, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('skipped if nothing to upgrade', () {
|
||||||
|
const String contents = '''
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>''';
|
||||||
|
xcodeProjectWorkspaceData.writeAsStringSync(contents);
|
||||||
|
|
||||||
|
final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration(
|
||||||
|
mockIosProject,
|
||||||
|
testLogger,
|
||||||
|
);
|
||||||
|
expect(iosProjectMigration.migrate(), isTrue);
|
||||||
|
expect(xcodeProjectWorkspaceData.existsSync(), isTrue);
|
||||||
|
expect(testLogger.statusText, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('Xcode project is migrated', () {
|
||||||
|
const String contents = '''
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "group:Runner.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:Pods/Pods.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
|
''';
|
||||||
|
xcodeProjectWorkspaceData.writeAsStringSync(contents);
|
||||||
|
|
||||||
|
final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration(
|
||||||
|
mockIosProject,
|
||||||
|
testLogger,
|
||||||
|
);
|
||||||
|
expect(iosProjectMigration.migrate(), isTrue);
|
||||||
|
expect(xcodeProjectWorkspaceData.readAsStringSync(), '''
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
|
|
||||||
|
''');
|
||||||
|
expect(testLogger.statusText, contains('Upgrading contents.xcworkspacedata'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
group('remove Runner project base configuration', () {
|
group('remove Runner project base configuration', () {
|
||||||
MemoryFileSystem memoryFileSystem;
|
MemoryFileSystem memoryFileSystem;
|
||||||
BufferLogger testLogger;
|
BufferLogger testLogger;
|
||||||
@ -348,15 +411,7 @@ keep this 2
|
|||||||
setUp(() {
|
setUp(() {
|
||||||
memoryFileSystem = MemoryFileSystem();
|
memoryFileSystem = MemoryFileSystem();
|
||||||
xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj');
|
xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj');
|
||||||
|
testLogger = BufferLogger.test();
|
||||||
testLogger = BufferLogger(
|
|
||||||
terminal: AnsiTerminal(
|
|
||||||
stdio: null,
|
|
||||||
platform: const LocalPlatform(),
|
|
||||||
),
|
|
||||||
outputPreferences: OutputPreferences.test(),
|
|
||||||
);
|
|
||||||
|
|
||||||
mockIosProject = MockIosProject();
|
mockIosProject = MockIosProject();
|
||||||
when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile);
|
when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user