Reverts "Enable Swift Package Manager by default on master channel (#152049)" (#152243)

Reverts: flutter/flutter#152049
Initiated by: cbracken
Reason for reverting: iOS builds failing in post-submit
Original PR Author: loic-sharma

Reviewed By: {jmagman}

This change reverts the following previous change:
Changes:

1. Enables Swift Package Manager by default on the main/master channel
2. Fixes tests that fail if Swift Package Manager is enabled

Corresponding docs change: https://github.com/flutter/website/pull/10938

Addresses https://github.com/flutter/flutter/issues/151567
This commit is contained in:
auto-submit[bot]
2024-07-24 16:49:25 +00:00
committed by GitHub
parent 08d8a7fa81
commit f55ab0e77e
9 changed files with 84 additions and 214 deletions

View File

@@ -186,7 +186,6 @@ const Feature swiftPackageManager = Feature(
environmentOverride: 'SWIFT_PACKAGE_MANAGER',
master: FeatureChannelSetting(
available: true,
enabledByDefault: true,
),
);

View File

@@ -693,7 +693,7 @@ void main() {
),
});
testUsingContext('kotlin/swift plugin project without Swift Package Manager', () async {
testUsingContext('kotlin/swift plugin project', () async {
return _createProject(
projectDir,
<String>['--no-pub', '--template=plugin', '-a', 'kotlin', '--ios-language', 'swift', '--platforms', 'ios,android'],
@@ -718,9 +718,6 @@ void main() {
'ios/Classes/FlutterProjectPlugin.m',
],
);
}, overrides: <Type, Generator>{
// Test flags disable Swift Package Manager.
FeatureFlags: () => TestFeatureFlags(),
});
testUsingContext('swift plugin project with Swift Package Manager', () async {
@@ -1947,7 +1944,7 @@ void main() {
);
});
testUsingContext('can re-gen plugin ios/ and example/ folders, reusing custom org, without Swift Package Manager', () async {
testUsingContext('can re-gen plugin ios/ and example/ folders, reusing custom org', () async {
await _createProject(
projectDir,
<String>[
@@ -1972,7 +1969,6 @@ void main() {
unexpectedPaths: <String>[
'example/android/app/src/main/java/com/example/flutter_project_example/MainActivity.java',
'android/src/main/java/com/example/flutter_project/FlutterProjectPlugin.java',
'ios/flutter_project/Sources/flutter_project/include/flutter_project/FlutterProjectPlugin.h',
],
);
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
@@ -1980,48 +1976,6 @@ void main() {
await project.example.ios.productBundleIdentifier(BuildInfo.debug),
'com.bar.foo.flutterProjectExample',
);
}, overrides: <Type, Generator>{
// Test flags disable Swift Package Manager.
FeatureFlags: () => TestFeatureFlags(),
});
testUsingContext('can re-gen plugin ios/ and example/ folders, reusing custom org, with Swift Package Manager', () async {
await _createProject(
projectDir,
<String>[
'--no-pub',
'--template=plugin',
'--org', 'com.bar.foo',
'-i', 'objc',
'-a', 'java',
'--platforms', 'ios,android',
],
<String>[],
);
projectDir.childDirectory('example').deleteSync(recursive: true);
projectDir.childDirectory('ios').deleteSync(recursive: true);
await _createProject(
projectDir,
<String>['--no-pub', '--template=plugin', '-i', 'objc', '-a', 'java', '--platforms', 'ios,android'],
<String>[
'example/android/app/src/main/java/com/bar/foo/flutter_project_example/MainActivity.java',
'ios/flutter_project/Sources/flutter_project/include/flutter_project/FlutterProjectPlugin.h',
],
unexpectedPaths: <String>[
'example/android/app/src/main/java/com/example/flutter_project_example/MainActivity.java',
'android/src/main/java/com/example/flutter_project/FlutterProjectPlugin.java',
'ios/Classes/FlutterProjectPlugin.h',
],
);
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
expect(
await project.example.ios.productBundleIdentifier(BuildInfo.debug),
'com.bar.foo.flutterProjectExample',
);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(
isSwiftPackageManagerEnabled: true,
),
});
testUsingContext('fails to re-gen without specified org when org is ambiguous', () async {

View File

@@ -404,7 +404,7 @@ void main() {
});
test('${swiftPackageManager.name} availability and default enabled', () {
expect(swiftPackageManager.master.enabledByDefault, true);
expect(swiftPackageManager.master.enabledByDefault, false);
expect(swiftPackageManager.master.available, true);
expect(swiftPackageManager.beta.enabledByDefault, false);
expect(swiftPackageManager.beta.available, false);

View File

@@ -87,7 +87,6 @@ void main() {
late File outputFlutterFrameworkBinary;
late Directory outputAppFramework;
late File outputAppFrameworkBinary;
late File outputRunnerBinary;
late File outputPluginFrameworkBinary;
late Directory buildPath;
late Directory buildAppFrameworkDsym;
@@ -123,10 +122,6 @@ void main() {
outputAppFramework = frameworkDirectory.childDirectory('App.framework');
outputAppFrameworkBinary = outputAppFramework.childFile('App');
outputRunnerBinary = outputApp.childFile('Runner');
// Exists only if the plugin is built as a dynamic framework.
// This is is the default for CocoaPods but not Swift Package Manager.
outputPluginFrameworkBinary = frameworkDirectory.childDirectory('hello.framework').childFile('hello');
buildPath = fileSystem.directory(fileSystem.path.join(
@@ -146,18 +141,7 @@ void main() {
printOnFailure(buildResult.stderr.toString());
expect(buildResult.exitCode, 0);
// Plugins are built either as a static library (SwiftPM's default)
// or as a dynamic library (CocoaPods's default).
// If built as a dynamic library, the plugin will have a .framework.
// If built as static library, the plugin's symbols will be in the
// Runner binary.
final bool helloDynamic = outputPluginFrameworkBinary.existsSync();
final bool helloStatic = AppleTestUtils
.getExportedSymbols(outputRunnerBinary.path)
.any((String symbol) => symbol.contains('HelloPlugin') && symbol.contains('handle'));
// Plugin is a dynamic xor static framework.
expect(helloDynamic != helloStatic, isTrue);
expect(outputPluginFrameworkBinary, exists);
expect(outputAppFrameworkBinary, exists);
expect(outputAppFramework.childFile('Info.plist'), exists);
@@ -316,19 +300,6 @@ void main() {
);
expect(buildSimulator.exitCode, 0);
// Plugins are built either as a static library (SwiftPM's default)
// or as a dynamic library (CocoaPods's default).
// If built as a dynamic library, the plugin will have a .framework.
// If built as static library, the plugin's symbols will be in the
// Runner binary.
final File runnerBinary = fileSystem.file(fileSystem.path.join(
projectRoot,
'build',
'ios',
'iphonesimulator',
'Runner.app',
'Runner',
));
final File pluginFrameworkBinary = fileSystem.file(fileSystem.path.join(
projectRoot,
'build',
@@ -339,21 +310,12 @@ void main() {
'hello.framework',
'hello',
));
final bool helloDynamic = pluginFrameworkBinary.existsSync();
final bool helloStatic = AppleTestUtils
.getExportedSymbols(runnerBinary.path)
.any((String symbol) => symbol.contains('HelloPlugin') && symbol.contains('handle'));
// Plugin is a dynamic xor static framework.
expect(helloDynamic != helloStatic, isTrue);
if (helloDynamic) {
final ProcessResult archs = processManager.runSync(
<String>['file', pluginFrameworkBinary.path],
);
expect(archs.stdout, contains('Mach-O 64-bit dynamically linked shared library x86_64'));
expect(archs.stdout, contains('Mach-O 64-bit dynamically linked shared library arm64'));
}
expect(pluginFrameworkBinary, exists);
final ProcessResult archs = processManager.runSync(
<String>['file', pluginFrameworkBinary.path],
);
expect(archs.stdout, contains('Mach-O 64-bit dynamically linked shared library x86_64'));
expect(archs.stdout, contains('Mach-O 64-bit dynamically linked shared library arm64'));
});
testWithoutContext('build for simulator with all available architectures', () {