mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
This reverts https://github.com/flutter/flutter/pull/158897 (commit
e7a1b68086
) as it is intended to be in the
same release as https://github.com/flutter/flutter/pull/161275.
However, https://github.com/flutter/flutter/pull/161275 had to be
reverted and won't be relanded until after the release cutoff. Hence,
I'm reverting this as well.
This commit is contained in:
parent
41a8939428
commit
593b40d3e4
@ -54,10 +54,6 @@ abstract class FeatureFlags {
|
|||||||
/// Whether Swift Package Manager dependency management is enabled.
|
/// Whether Swift Package Manager dependency management is enabled.
|
||||||
bool get isSwiftPackageManagerEnabled => false;
|
bool get isSwiftPackageManagerEnabled => false;
|
||||||
|
|
||||||
/// Whether apps are automatically migrated to add Swift Package Manager
|
|
||||||
/// integration. Requires [isSwiftPackageManagerEnabled].
|
|
||||||
bool get isSwiftPackageManagerMigrationEnabled => false;
|
|
||||||
|
|
||||||
/// Whether explicit package dependency management is enabled.
|
/// Whether explicit package dependency management is enabled.
|
||||||
bool get isExplicitPackageDependenciesEnabled => false;
|
bool get isExplicitPackageDependenciesEnabled => false;
|
||||||
|
|
||||||
@ -81,7 +77,6 @@ const List<Feature> allFeatures = <Feature>[
|
|||||||
nativeAssets,
|
nativeAssets,
|
||||||
previewDevice,
|
previewDevice,
|
||||||
swiftPackageManager,
|
swiftPackageManager,
|
||||||
swiftPackageManagerMigration,
|
|
||||||
explicitPackageDependencies,
|
explicitPackageDependencies,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -183,16 +178,6 @@ const Feature swiftPackageManager = Feature(
|
|||||||
stable: FeatureChannelSetting(available: true),
|
stable: FeatureChannelSetting(available: true),
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Enable migrating iOS and macOS apps to add Swift Package Manager integration.
|
|
||||||
const Feature swiftPackageManagerMigration = Feature(
|
|
||||||
name: 'migrate iOS and macOS apps to add Swift Package Manager integration',
|
|
||||||
configSetting: 'enable-swift-package-manager-migration',
|
|
||||||
environmentOverride: 'FLUTTER_SWIFT_PACKAGE_MANAGER_MIGRATION',
|
|
||||||
master: FeatureChannelSetting(available: true),
|
|
||||||
beta: FeatureChannelSetting(available: true),
|
|
||||||
stable: FeatureChannelSetting(available: true),
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Enable explicit resolution and generation of package dependencies.
|
/// Enable explicit resolution and generation of package dependencies.
|
||||||
const Feature explicitPackageDependencies = Feature(
|
const Feature explicitPackageDependencies = Feature(
|
||||||
name: 'support for dev_dependency plugins',
|
name: 'support for dev_dependency plugins',
|
||||||
|
@ -61,15 +61,6 @@ class FlutterFeatureFlags implements FeatureFlags {
|
|||||||
@override
|
@override
|
||||||
bool get isSwiftPackageManagerEnabled => isEnabled(swiftPackageManager);
|
bool get isSwiftPackageManagerEnabled => isEnabled(swiftPackageManager);
|
||||||
|
|
||||||
@override
|
|
||||||
bool get isSwiftPackageManagerMigrationEnabled {
|
|
||||||
if (!isEnabled(swiftPackageManager)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isEnabled(swiftPackageManagerMigration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get isExplicitPackageDependenciesEnabled => isEnabled(explicitPackageDependencies);
|
bool get isExplicitPackageDependenciesEnabled => isEnabled(explicitPackageDependencies);
|
||||||
|
|
||||||
|
@ -118,14 +118,6 @@ class SwiftPackageManagerIntegrationMigration extends ProjectMigrator {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_features.isSwiftPackageManagerMigrationEnabled) {
|
|
||||||
logger.printTrace(
|
|
||||||
'The migration to add Swift Package Manager integration is off. '
|
|
||||||
'Skipping...',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_xcodeProject.flutterPluginSwiftPackageManifest.existsSync()) {
|
if (!_xcodeProject.flutterPluginSwiftPackageManifest.existsSync()) {
|
||||||
logger.printTrace(
|
logger.printTrace(
|
||||||
'The tool did not generate a Swift package. '
|
'The tool did not generate a Swift package. '
|
||||||
|
@ -182,15 +182,6 @@ abstract class XcodeBasedProject extends FlutterProjectPlatform {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the project doesn't have Swift Package Manager integration yet,
|
|
||||||
// the SwiftPM migration feature is required (as that will add SwiftPM
|
|
||||||
// integration to the project).
|
|
||||||
if (!flutterPluginSwiftPackageInProjectSettings) {
|
|
||||||
if (!featureFlags.isSwiftPackageManagerMigrationEnabled) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('Swift Package Manager feature', () {
|
group('Swift Package Manager feature', () {
|
||||||
testWithoutContext('availability and default enabled', () {
|
test('availability and default enabled', () {
|
||||||
expect(swiftPackageManager.master.enabledByDefault, false);
|
expect(swiftPackageManager.master.enabledByDefault, false);
|
||||||
expect(swiftPackageManager.master.available, true);
|
expect(swiftPackageManager.master.available, true);
|
||||||
expect(swiftPackageManager.beta.enabledByDefault, false);
|
expect(swiftPackageManager.beta.enabledByDefault, false);
|
||||||
@ -418,52 +418,11 @@ void main() {
|
|||||||
expect(swiftPackageManager.stable.available, true);
|
expect(swiftPackageManager.stable.available, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('can be enabled', () {
|
test('can be enabled', () {
|
||||||
platform.environment = <String, String>{'FLUTTER_SWIFT_PACKAGE_MANAGER': 'true'};
|
platform.environment = <String, String>{'FLUTTER_SWIFT_PACKAGE_MANAGER': 'true'};
|
||||||
|
|
||||||
expect(featureFlags.isSwiftPackageManagerEnabled, isTrue);
|
expect(featureFlags.isSwiftPackageManagerEnabled, isTrue);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('Swift Package Manager app migration feature', () {
|
|
||||||
testWithoutContext('availability and default enabled', () {
|
|
||||||
expect(swiftPackageManagerMigration.master.enabledByDefault, false);
|
|
||||||
expect(swiftPackageManagerMigration.master.available, true);
|
|
||||||
expect(swiftPackageManagerMigration.beta.enabledByDefault, false);
|
|
||||||
expect(swiftPackageManagerMigration.beta.available, true);
|
|
||||||
expect(swiftPackageManagerMigration.stable.enabledByDefault, false);
|
|
||||||
expect(swiftPackageManagerMigration.stable.available, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWithoutContext('requires Swift Package Manager feature', () {
|
|
||||||
platform.environment = <String, String>{
|
|
||||||
'FLUTTER_SWIFT_PACKAGE_MANAGER': 'false',
|
|
||||||
'FLUTTER_SWIFT_PACKAGE_MANAGER_MIGRATION': 'true',
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(featureFlags.isSwiftPackageManagerEnabled, isFalse);
|
|
||||||
expect(featureFlags.isSwiftPackageManagerMigrationEnabled, isFalse);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWithoutContext('is separate from the Swift Package Manager feature', () {
|
|
||||||
platform.environment = <String, String>{
|
|
||||||
'FLUTTER_SWIFT_PACKAGE_MANAGER': 'true',
|
|
||||||
'FLUTTER_SWIFT_PACKAGE_MANAGER_MIGRATION': 'false',
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(featureFlags.isSwiftPackageManagerEnabled, isTrue);
|
|
||||||
expect(featureFlags.isSwiftPackageManagerMigrationEnabled, isFalse);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWithoutContext('can be enabled', () {
|
|
||||||
platform.environment = <String, String>{
|
|
||||||
'FLUTTER_SWIFT_PACKAGE_MANAGER': 'true',
|
|
||||||
'FLUTTER_SWIFT_PACKAGE_MANAGER_MIGRATION': 'true',
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(featureFlags.isSwiftPackageManagerEnabled, isTrue);
|
|
||||||
expect(featureFlags.isSwiftPackageManagerEnabled, isTrue);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -566,11 +566,7 @@ void main() {
|
|||||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
},
|
},
|
||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
FeatureFlags:
|
FeatureFlags: () => TestFeatureFlags(isSwiftPackageManagerEnabled: true),
|
||||||
() => TestFeatureFlags(
|
|
||||||
isSwiftPackageManagerEnabled: true,
|
|
||||||
isSwiftPackageManagerMigrationEnabled: true,
|
|
||||||
),
|
|
||||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(version: Version(15, 0, 0)),
|
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(version: Version(15, 0, 0)),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -25,11 +25,10 @@ const List<SupportedPlatform> supportedPlatforms = <SupportedPlatform>[
|
|||||||
void main() {
|
void main() {
|
||||||
final TestFeatureFlags swiftPackageManagerFullyEnabledFlags = TestFeatureFlags(
|
final TestFeatureFlags swiftPackageManagerFullyEnabledFlags = TestFeatureFlags(
|
||||||
isSwiftPackageManagerEnabled: true,
|
isSwiftPackageManagerEnabled: true,
|
||||||
isSwiftPackageManagerMigrationEnabled: true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
group('Flutter Package Migration', () {
|
group('Flutter Package Migration', () {
|
||||||
testWithoutContext('skips if Swift Package Manager is off', () async {
|
testWithoutContext('skips if swift package manager is off', () async {
|
||||||
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
|
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
|
||||||
final BufferLogger testLogger = BufferLogger.test();
|
final BufferLogger testLogger = BufferLogger.test();
|
||||||
|
|
||||||
@ -46,9 +45,8 @@ void main() {
|
|||||||
logger: testLogger,
|
logger: testLogger,
|
||||||
fileSystem: memoryFileSystem,
|
fileSystem: memoryFileSystem,
|
||||||
plistParser: FakePlistParser(),
|
plistParser: FakePlistParser(),
|
||||||
features: TestFeatureFlags(isSwiftPackageManagerMigrationEnabled: true),
|
features: TestFeatureFlags(),
|
||||||
);
|
);
|
||||||
|
|
||||||
await projectMigration.migrate();
|
await projectMigration.migrate();
|
||||||
expect(
|
expect(
|
||||||
testLogger.traceText,
|
testLogger.traceText,
|
||||||
@ -57,36 +55,6 @@ void main() {
|
|||||||
expect(testLogger.statusText, isEmpty);
|
expect(testLogger.statusText, isEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('skips if Swift Package Manager migration is off', () async {
|
|
||||||
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
|
|
||||||
final BufferLogger testLogger = BufferLogger.test();
|
|
||||||
|
|
||||||
final SwiftPackageManagerIntegrationMigration projectMigration =
|
|
||||||
SwiftPackageManagerIntegrationMigration(
|
|
||||||
FakeXcodeProject(
|
|
||||||
platform: SupportedPlatform.ios.name,
|
|
||||||
fileSystem: memoryFileSystem,
|
|
||||||
logger: testLogger,
|
|
||||||
),
|
|
||||||
SupportedPlatform.ios,
|
|
||||||
BuildInfo.debug,
|
|
||||||
xcodeProjectInterpreter: FakeXcodeProjectInterpreter(),
|
|
||||||
logger: testLogger,
|
|
||||||
fileSystem: memoryFileSystem,
|
|
||||||
plistParser: FakePlistParser(),
|
|
||||||
features: TestFeatureFlags(isSwiftPackageManagerEnabled: true),
|
|
||||||
);
|
|
||||||
await projectMigration.migrate();
|
|
||||||
expect(
|
|
||||||
testLogger.traceText,
|
|
||||||
contains(
|
|
||||||
'The migration to add Swift Package Manager integration is off. '
|
|
||||||
'Skipping...',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(testLogger.statusText, isEmpty);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWithoutContext("skips if there's no generated swift package", () async {
|
testWithoutContext("skips if there's no generated swift package", () async {
|
||||||
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
|
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
|
||||||
final BufferLogger testLogger = BufferLogger.test();
|
final BufferLogger testLogger = BufferLogger.test();
|
||||||
|
@ -122,7 +122,7 @@ void main() {
|
|||||||
|
|
||||||
group('usesSwiftPackageManager', () {
|
group('usesSwiftPackageManager', () {
|
||||||
testUsingContext(
|
testUsingContext(
|
||||||
'is true if the feature is on',
|
'is true when iOS project exists',
|
||||||
() async {
|
() async {
|
||||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
final MemoryFileSystem fs = MemoryFileSystem.test();
|
||||||
final Directory projectDirectory = fs.directory('path');
|
final Directory projectDirectory = fs.directory('path');
|
||||||
@ -131,35 +131,6 @@ void main() {
|
|||||||
final FlutterProject project = FlutterProject(projectDirectory, manifest, manifest);
|
final FlutterProject project = FlutterProject(projectDirectory, manifest, manifest);
|
||||||
expect(project.ios.usesSwiftPackageManager, isTrue);
|
expect(project.ios.usesSwiftPackageManager, isTrue);
|
||||||
},
|
},
|
||||||
overrides: <Type, Generator>{
|
|
||||||
FeatureFlags:
|
|
||||||
() => TestFeatureFlags(
|
|
||||||
isSwiftPackageManagerEnabled: true,
|
|
||||||
isSwiftPackageManagerMigrationEnabled: true,
|
|
||||||
),
|
|
||||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(version: Version(15, 0, 0)),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
testUsingContext(
|
|
||||||
'is true if migration feature is off but project is migrated',
|
|
||||||
() async {
|
|
||||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
|
||||||
final Directory projectDirectory = fs.directory('path');
|
|
||||||
projectDirectory.childDirectory('ios').createSync(recursive: true);
|
|
||||||
|
|
||||||
// Create an Xcode project that appears to have SwiftPM integration.
|
|
||||||
final File xcodeProjectFile = projectDirectory
|
|
||||||
.childDirectory('ios')
|
|
||||||
.childDirectory('Runner.xcodeproj')
|
|
||||||
.childFile('project.pbxproj');
|
|
||||||
xcodeProjectFile.createSync(recursive: true);
|
|
||||||
xcodeProjectFile.writeAsStringSync('FlutterGeneratedPluginSwiftPackage');
|
|
||||||
|
|
||||||
final FlutterManifest manifest = FakeFlutterManifest();
|
|
||||||
final FlutterProject project = FlutterProject(projectDirectory, manifest, manifest);
|
|
||||||
expect(project.ios.usesSwiftPackageManager, isTrue);
|
|
||||||
},
|
|
||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
FeatureFlags: () => TestFeatureFlags(isSwiftPackageManagerEnabled: true),
|
FeatureFlags: () => TestFeatureFlags(isSwiftPackageManagerEnabled: true),
|
||||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(version: Version(15, 0, 0)),
|
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(version: Version(15, 0, 0)),
|
||||||
@ -283,7 +254,7 @@ void main() {
|
|||||||
|
|
||||||
group('usesSwiftPackageManager', () {
|
group('usesSwiftPackageManager', () {
|
||||||
testUsingContext(
|
testUsingContext(
|
||||||
'is true if feature on',
|
'is true when macOS project exists',
|
||||||
() async {
|
() async {
|
||||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
final MemoryFileSystem fs = MemoryFileSystem.test();
|
||||||
final Directory projectDirectory = fs.directory('path');
|
final Directory projectDirectory = fs.directory('path');
|
||||||
@ -292,35 +263,6 @@ void main() {
|
|||||||
final FlutterProject project = FlutterProject(projectDirectory, manifest, manifest);
|
final FlutterProject project = FlutterProject(projectDirectory, manifest, manifest);
|
||||||
expect(project.macos.usesSwiftPackageManager, isTrue);
|
expect(project.macos.usesSwiftPackageManager, isTrue);
|
||||||
},
|
},
|
||||||
overrides: <Type, Generator>{
|
|
||||||
FeatureFlags:
|
|
||||||
() => TestFeatureFlags(
|
|
||||||
isSwiftPackageManagerEnabled: true,
|
|
||||||
isSwiftPackageManagerMigrationEnabled: true,
|
|
||||||
),
|
|
||||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(version: Version(15, 0, 0)),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
testUsingContext(
|
|
||||||
'is true if migration feature is off but project is migrated',
|
|
||||||
() async {
|
|
||||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
|
||||||
final Directory projectDirectory = fs.directory('path');
|
|
||||||
projectDirectory.childDirectory('macos').createSync(recursive: true);
|
|
||||||
|
|
||||||
// Create an Xcode project that appears to have SwiftPM integration.
|
|
||||||
final File xcodeProjectFile = projectDirectory
|
|
||||||
.childDirectory('macos')
|
|
||||||
.childDirectory('Runner.xcodeproj')
|
|
||||||
.childFile('project.pbxproj');
|
|
||||||
xcodeProjectFile.createSync(recursive: true);
|
|
||||||
xcodeProjectFile.writeAsStringSync('FlutterGeneratedPluginSwiftPackage');
|
|
||||||
|
|
||||||
final FlutterManifest manifest = FakeFlutterManifest();
|
|
||||||
final FlutterProject project = FlutterProject(projectDirectory, manifest, manifest);
|
|
||||||
expect(project.macos.usesSwiftPackageManager, isTrue);
|
|
||||||
},
|
|
||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
FeatureFlags: () => TestFeatureFlags(isSwiftPackageManagerEnabled: true),
|
FeatureFlags: () => TestFeatureFlags(isSwiftPackageManagerEnabled: true),
|
||||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(version: Version(15, 0, 0)),
|
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(version: Version(15, 0, 0)),
|
||||||
|
@ -861,210 +861,4 @@ void main() {
|
|||||||
expect(generatedManifest, contains(emptyDependencies));
|
expect(generatedManifest, contains(emptyDependencies));
|
||||||
expect(cocoaPodsPluginFramework, exists);
|
expect(cocoaPodsPluginFramework, exists);
|
||||||
}, skip: !platform.isMacOS); // [intended] Swift Package Manager only works on macos.
|
}, skip: !platform.isMacOS); // [intended] Swift Package Manager only works on macos.
|
||||||
|
|
||||||
test(
|
|
||||||
'App is not migrated if Swift Package Manager is turned on but not migration',
|
|
||||||
() async {
|
|
||||||
final Directory workingDirectory = fileSystem.systemTempDirectory.createTempSync(
|
|
||||||
'swift_package_manager_spm_on_migration_off_legacy_app.',
|
|
||||||
);
|
|
||||||
final String workingDirectoryPath = workingDirectory.path;
|
|
||||||
|
|
||||||
addTearDown(() async {
|
|
||||||
await SwiftPackageManagerUtils.disableSwiftPackageManager(flutterBin, workingDirectoryPath);
|
|
||||||
ErrorHandlingFileSystem.deleteIfExists(workingDirectory, recursive: true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create an app that uses CocoaPods.
|
|
||||||
await SwiftPackageManagerUtils.disableSwiftPackageManager(flutterBin, workingDirectoryPath);
|
|
||||||
final String appDirectoryPath = await SwiftPackageManagerUtils.createApp(
|
|
||||||
flutterBin,
|
|
||||||
workingDirectoryPath,
|
|
||||||
iosLanguage: 'swift',
|
|
||||||
platform: 'ios',
|
|
||||||
options: <String>['--platforms=ios'],
|
|
||||||
);
|
|
||||||
final SwiftPackageManagerPlugin integrationTestPlugin =
|
|
||||||
SwiftPackageManagerUtils.integrationTestPlugin('ios');
|
|
||||||
SwiftPackageManagerUtils.addDependency(
|
|
||||||
appDirectoryPath: appDirectoryPath,
|
|
||||||
plugin: integrationTestPlugin,
|
|
||||||
);
|
|
||||||
|
|
||||||
await SwiftPackageManagerUtils.buildApp(
|
|
||||||
flutterBin,
|
|
||||||
appDirectoryPath,
|
|
||||||
options: <String>['ios', '--config-only', '-v'],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Turn on the Swift Package Manager feature but not the app migration
|
|
||||||
// and build the app.
|
|
||||||
await SwiftPackageManagerUtils.cleanApp(flutterBin, appDirectoryPath);
|
|
||||||
await SwiftPackageManagerUtils.enableSwiftPackageManager(
|
|
||||||
flutterBin,
|
|
||||||
workingDirectoryPath,
|
|
||||||
enableMigration: false,
|
|
||||||
);
|
|
||||||
await SwiftPackageManagerUtils.buildApp(
|
|
||||||
flutterBin,
|
|
||||||
appDirectoryPath,
|
|
||||||
options: <String>['ios', '-v'],
|
|
||||||
);
|
|
||||||
|
|
||||||
// The app should be built using CocoaPods.
|
|
||||||
// The app should not have been migrated to add SwiftPM integration.
|
|
||||||
final File xcodeProjectFile = fileSystem
|
|
||||||
.directory(appDirectoryPath)
|
|
||||||
.childDirectory('ios')
|
|
||||||
.childDirectory('Runner.xcodeproj')
|
|
||||||
.childFile('project.pbxproj');
|
|
||||||
final File generatedManifestFile = fileSystem
|
|
||||||
.directory(appDirectoryPath)
|
|
||||||
.childDirectory('ios')
|
|
||||||
.childDirectory('Flutter')
|
|
||||||
.childDirectory('ephemeral')
|
|
||||||
.childDirectory('Packages')
|
|
||||||
.childDirectory('FlutterGeneratedPluginSwiftPackage')
|
|
||||||
.childFile('Package.swift');
|
|
||||||
final Directory cocoaPodsPluginFramework = fileSystem
|
|
||||||
.directory(appDirectoryPath)
|
|
||||||
.childDirectory('build')
|
|
||||||
.childDirectory('ios')
|
|
||||||
.childDirectory('iphoneos')
|
|
||||||
.childDirectory('Runner.app')
|
|
||||||
.childDirectory('Frameworks')
|
|
||||||
.childDirectory('${integrationTestPlugin.pluginName}.framework');
|
|
||||||
|
|
||||||
expect(xcodeProjectFile, exists);
|
|
||||||
expect(generatedManifestFile, isNot(exists));
|
|
||||||
expect(cocoaPodsPluginFramework, exists);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
xcodeProjectFile.readAsStringSync(),
|
|
||||||
isNot(contains('FlutterGeneratedPluginSwiftPackage')),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
skip: !platform.isMacOS, // [intended] Swift Package Manager only works on macos.
|
|
||||||
);
|
|
||||||
|
|
||||||
test('iOS can use Swift Package Manager while macOS uses CocoaPods', () async {
|
|
||||||
final Directory workingDirectory = fileSystem.systemTempDirectory.createTempSync(
|
|
||||||
'swift_package_manager_ios_on_cocoapods_macos_on_swiftpm.',
|
|
||||||
);
|
|
||||||
final String workingDirectoryPath = workingDirectory.path;
|
|
||||||
|
|
||||||
addTearDown(() async {
|
|
||||||
await SwiftPackageManagerUtils.disableSwiftPackageManager(flutterBin, workingDirectoryPath);
|
|
||||||
ErrorHandlingFileSystem.deleteIfExists(workingDirectory, recursive: true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create an app that uses CocoaPods.
|
|
||||||
await SwiftPackageManagerUtils.disableSwiftPackageManager(flutterBin, workingDirectoryPath);
|
|
||||||
final String appDirectoryPath = await SwiftPackageManagerUtils.createApp(
|
|
||||||
flutterBin,
|
|
||||||
workingDirectoryPath,
|
|
||||||
iosLanguage: 'swift',
|
|
||||||
platform: 'ios',
|
|
||||||
options: <String>['--platforms=ios,macos'],
|
|
||||||
);
|
|
||||||
final SwiftPackageManagerPlugin integrationTestPlugin =
|
|
||||||
SwiftPackageManagerUtils.integrationTestPlugin('ios');
|
|
||||||
SwiftPackageManagerUtils.addDependency(
|
|
||||||
appDirectoryPath: appDirectoryPath,
|
|
||||||
plugin: integrationTestPlugin,
|
|
||||||
);
|
|
||||||
|
|
||||||
await SwiftPackageManagerUtils.buildApp(
|
|
||||||
flutterBin,
|
|
||||||
appDirectoryPath,
|
|
||||||
options: <String>['ios', '--config-only', '-v'],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Turn on the Swift Package Manager feature and its migration and build
|
|
||||||
// the iOS app. This migrates the iOS app to Swift Package Manager - but not
|
|
||||||
// the macOS app!
|
|
||||||
await SwiftPackageManagerUtils.cleanApp(flutterBin, appDirectoryPath);
|
|
||||||
await SwiftPackageManagerUtils.enableSwiftPackageManager(flutterBin, workingDirectoryPath);
|
|
||||||
await SwiftPackageManagerUtils.buildApp(
|
|
||||||
flutterBin,
|
|
||||||
appDirectoryPath,
|
|
||||||
options: <String>['ios', '-v'],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Turn off the migration but turn on the Swift Package Manager feature.
|
|
||||||
await SwiftPackageManagerUtils.cleanApp(flutterBin, appDirectoryPath);
|
|
||||||
await SwiftPackageManagerUtils.disableSwiftPackageManager(flutterBin, workingDirectoryPath);
|
|
||||||
await SwiftPackageManagerUtils.enableSwiftPackageManager(
|
|
||||||
flutterBin,
|
|
||||||
workingDirectoryPath,
|
|
||||||
enableMigration: false,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Build the iOS and macOS apps. iOS should build using Swift Package Manager,
|
|
||||||
// macOS should build using CocoaPods.
|
|
||||||
await SwiftPackageManagerUtils.buildApp(
|
|
||||||
flutterBin,
|
|
||||||
appDirectoryPath,
|
|
||||||
options: <String>['ios', '--config-only', '-v'],
|
|
||||||
);
|
|
||||||
await SwiftPackageManagerUtils.buildApp(
|
|
||||||
flutterBin,
|
|
||||||
appDirectoryPath,
|
|
||||||
options: <String>['macos', '--config-only', '-v'],
|
|
||||||
);
|
|
||||||
|
|
||||||
final File flutterPluginsDependenciesFile = fileSystem
|
|
||||||
.directory(appDirectoryPath)
|
|
||||||
.childFile('.flutter-plugins-dependencies');
|
|
||||||
|
|
||||||
final File generatedSwiftPackageIos = fileSystem
|
|
||||||
.directory(appDirectoryPath)
|
|
||||||
.childDirectory('ios')
|
|
||||||
.childDirectory('Flutter')
|
|
||||||
.childDirectory('ephemeral')
|
|
||||||
.childDirectory('Packages')
|
|
||||||
.childDirectory('FlutterGeneratedPluginSwiftPackage')
|
|
||||||
.childFile('Package.swift');
|
|
||||||
final File generatedSwiftPackageMacos = fileSystem
|
|
||||||
.directory(appDirectoryPath)
|
|
||||||
.childDirectory('macos')
|
|
||||||
.childDirectory('Flutter')
|
|
||||||
.childDirectory('ephemeral')
|
|
||||||
.childDirectory('Packages')
|
|
||||||
.childDirectory('FlutterGeneratedPluginSwiftPackage')
|
|
||||||
.childFile('Package.swift');
|
|
||||||
|
|
||||||
final File xcodeProjectFileIos = fileSystem
|
|
||||||
.directory(appDirectoryPath)
|
|
||||||
.childDirectory('ios')
|
|
||||||
.childDirectory('Runner.xcodeproj')
|
|
||||||
.childFile('project.pbxproj');
|
|
||||||
final File xcodeProjectFileMacos = fileSystem
|
|
||||||
.directory(appDirectoryPath)
|
|
||||||
.childDirectory('macos')
|
|
||||||
.childDirectory('Runner.xcodeproj')
|
|
||||||
.childFile('project.pbxproj');
|
|
||||||
|
|
||||||
// The build should have used SwiftPM for iOS but CocoaPods for macOS.
|
|
||||||
expect(flutterPluginsDependenciesFile, exists);
|
|
||||||
expect(generatedSwiftPackageIos, exists);
|
|
||||||
expect(generatedSwiftPackageMacos, isNot(exists));
|
|
||||||
expect(xcodeProjectFileIos, exists);
|
|
||||||
expect(xcodeProjectFileMacos, exists);
|
|
||||||
|
|
||||||
final String dependenciesString = flutterPluginsDependenciesFile.readAsStringSync();
|
|
||||||
final Map<String, dynamic> dependenciesJson =
|
|
||||||
json.decode(dependenciesString) as Map<String, dynamic>;
|
|
||||||
|
|
||||||
expect(dependenciesJson['swift_package_manager_enabled'], <String, bool>{
|
|
||||||
'ios': true,
|
|
||||||
'macos': false,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(xcodeProjectFileIos.readAsStringSync(), contains('FlutterGeneratedPluginSwiftPackage'));
|
|
||||||
expect(
|
|
||||||
xcodeProjectFileMacos.readAsStringSync(),
|
|
||||||
isNot(contains('FlutterGeneratedPluginSwiftPackage')),
|
|
||||||
);
|
|
||||||
}, skip: !platform.isMacOS); // [intended] Swift Package Manager only works on macos.
|
|
||||||
}
|
}
|
||||||
|
@ -6,78 +6,43 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/features.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_utils.dart';
|
import 'test_utils.dart';
|
||||||
|
|
||||||
class SwiftPackageManagerUtils {
|
class SwiftPackageManagerUtils {
|
||||||
static Future<void> enableSwiftPackageManager(
|
static Future<void> enableSwiftPackageManager(String flutterBin, String workingDirectory) async {
|
||||||
String flutterBin,
|
|
||||||
String workingDirectory, {
|
|
||||||
bool enableMigration = true,
|
|
||||||
}) async {
|
|
||||||
await _enableFeature(flutterBin, workingDirectory, swiftPackageManager);
|
|
||||||
|
|
||||||
if (enableMigration) {
|
|
||||||
await _enableFeature(flutterBin, workingDirectory, swiftPackageManagerMigration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<void> disableSwiftPackageManager(
|
|
||||||
String flutterBin,
|
|
||||||
String workingDirectory, {
|
|
||||||
bool disableMigration = true,
|
|
||||||
}) async {
|
|
||||||
if (disableMigration) {
|
|
||||||
await _disableFeature(flutterBin, workingDirectory, swiftPackageManagerMigration);
|
|
||||||
}
|
|
||||||
|
|
||||||
await _disableFeature(flutterBin, workingDirectory, swiftPackageManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<void> _enableFeature(
|
|
||||||
String flutterBin,
|
|
||||||
String workingDirectory,
|
|
||||||
Feature feature,
|
|
||||||
) async {
|
|
||||||
final ProcessResult result = await processManager.run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
...getLocalEngineArguments(),
|
...getLocalEngineArguments(),
|
||||||
'config',
|
'config',
|
||||||
'--${feature.configSetting}',
|
'--enable-swift-package-manager',
|
||||||
'-v',
|
'-v',
|
||||||
], workingDirectory: workingDirectory);
|
], workingDirectory: workingDirectory);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
result.exitCode,
|
result.exitCode,
|
||||||
0,
|
0,
|
||||||
reason:
|
reason:
|
||||||
'Failed to enable feature "${feature.name}": \n'
|
'Failed to enable Swift Package Manager: \n'
|
||||||
'stdout: \n${result.stdout}\n'
|
'stdout: \n${result.stdout}\n'
|
||||||
'stderr: \n${result.stderr}\n',
|
'stderr: \n${result.stderr}\n',
|
||||||
verbose: true,
|
verbose: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> _disableFeature(
|
static Future<void> disableSwiftPackageManager(String flutterBin, String workingDirectory) async {
|
||||||
String flutterBin,
|
|
||||||
String workingDirectory,
|
|
||||||
Feature feature,
|
|
||||||
) async {
|
|
||||||
final ProcessResult result = await processManager.run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
...getLocalEngineArguments(),
|
...getLocalEngineArguments(),
|
||||||
'config',
|
'config',
|
||||||
'--no-${feature.configSetting}',
|
'--no-enable-swift-package-manager',
|
||||||
'-v',
|
'-v',
|
||||||
], workingDirectory: workingDirectory);
|
], workingDirectory: workingDirectory);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
result.exitCode,
|
result.exitCode,
|
||||||
0,
|
0,
|
||||||
reason:
|
reason:
|
||||||
'Failed to disable feature "${feature.name}": \n'
|
'Failed to disable Swift Package Manager: \n'
|
||||||
'stdout: \n${result.stdout}\n'
|
'stdout: \n${result.stdout}\n'
|
||||||
'stderr: \n${result.stderr}\n',
|
'stderr: \n${result.stderr}\n',
|
||||||
verbose: true,
|
verbose: true,
|
||||||
|
@ -489,7 +489,6 @@ class TestFeatureFlags implements FeatureFlags {
|
|||||||
this.isNativeAssetsEnabled = false,
|
this.isNativeAssetsEnabled = false,
|
||||||
this.isPreviewDeviceEnabled = false,
|
this.isPreviewDeviceEnabled = false,
|
||||||
this.isSwiftPackageManagerEnabled = false,
|
this.isSwiftPackageManagerEnabled = false,
|
||||||
this.isSwiftPackageManagerMigrationEnabled = false,
|
|
||||||
this.isExplicitPackageDependenciesEnabled = false,
|
this.isExplicitPackageDependenciesEnabled = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -529,9 +528,6 @@ class TestFeatureFlags implements FeatureFlags {
|
|||||||
@override
|
@override
|
||||||
final bool isSwiftPackageManagerEnabled;
|
final bool isSwiftPackageManagerEnabled;
|
||||||
|
|
||||||
@override
|
|
||||||
final bool isSwiftPackageManagerMigrationEnabled;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final bool isExplicitPackageDependenciesEnabled;
|
final bool isExplicitPackageDependenciesEnabled;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user