Skip to content

Conversation

@loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Aug 20, 2024

When a Flutter app is migrated to add Swift Package Manager integration, the Xcode project is modified to depend on a local Swift package that's generated by the Flutter tool. This generated package is how plugins are added to the Xcode project if the SwiftPM feature is enabled.

If an app has been migrated to SwiftPM but Flutter's SwiftPM feature is disabled, the tool must continue to generate a Swift package to ensure the app continues to build. Otherwise, the Xcode project would depend on a local package that does not exist.

This adds a high-level integration test that ensures this behavior works as expected, which mirrors this finer-grained unit test:

group('when not using Swift Package Manager', () {
testWithoutContext('but project already migrated', () async {
final MemoryFileSystem fs = MemoryFileSystem();
final BufferLogger testLogger = BufferLogger.test();
final File cocoapodPluginPodspec = fs.file('/path/to/cocoapod_plugin_1/darwin/cocoapod_plugin_1.podspec')
..createSync(recursive: true);
final List<Plugin> plugins = <Plugin>[
FakePlugin(
name: 'cocoapod_plugin_1',
platforms: <String, PluginPlatform>{platform.name: FakePluginPlatform()},
pluginPodspecPath: cocoapodPluginPodspec.path,
),
];
final FakeSwiftPackageManager swiftPackageManager = FakeSwiftPackageManager(
expectedPlugins: plugins,
);
final FakeCocoaPods cocoaPods = FakeCocoaPods();
final FakeFlutterProject project = FakeFlutterProject(
usesSwiftPackageManager: true,
fileSystem: fs,
);
final XcodeBasedProject xcodeProject = platform == SupportedPlatform.ios ? project.ios : project.macos;
xcodeProject.xcodeProjectInfoFile.createSync(recursive: true);
xcodeProject.xcodeProjectInfoFile.writeAsStringSync(
'FlutterGeneratedPluginSwiftPackage',
);
final DarwinDependencyManagement dependencyManagement = DarwinDependencyManagement(
project: project,
plugins: plugins,
cocoapods: cocoaPods,
swiftPackageManager: swiftPackageManager,
fileSystem: fs,
logger: testLogger,
);
await dependencyManagement.setUp(
platform: platform,
);
expect(swiftPackageManager.generated, isTrue);
expect(testLogger.warningText, isEmpty);
expect(testLogger.statusText, isEmpty);
expect(cocoaPods.podfileSetup, isTrue);
});

Part of #153448

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 20, 2024
@loic-sharma loic-sharma requested a review from jmagman August 21, 2024 17:46
@loic-sharma loic-sharma marked this pull request as ready for review August 21, 2024 17:46
@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 21, 2024
@auto-submit auto-submit bot merged commit 88d9f61 into flutter:master Aug 21, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 1, 2024
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
… off (flutter#153800)

When a Flutter app is migrated to add Swift Package Manager integration, the Xcode project is modified to depend on a local Swift package that's generated by the Flutter tool. This generated package is how plugins are added to the Xcode project if the SwiftPM feature is enabled.

If an app has been migrated to SwiftPM but Flutter's SwiftPM feature is disabled, the [tool must continue to generate a Swift package](https://github.com/flutter/flutter/blob/47c1df9640f8812bed40dc1174dc4acd0eb7fd86/packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart#L69-L78) to ensure the app continues to build. Otherwise, the Xcode project would depend on a local package that does not exist.

This adds a high-level integration test that ensures this behavior works as expected, which mirrors this finer-grained unit test: https://github.com/flutter/flutter/blob/47c1df9640f8812bed40dc1174dc4acd0eb7fd86/packages/flutter_tools/test/general.shard/macos/darwin_dependency_management_test.dart#L340-L382

Part of flutter#153448
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants