Skip to content

Commit 0093c6a

Browse files
authored
Add Podfile migration warning to support federated plugins (flutter#59201)
1 parent 97dc7ee commit 0093c6a

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

packages/flutter_tools/lib/src/macos/cocoapods.dart

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ const String brokenCocoaPodsConsequence = '''
3333
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
3434
This can usually be fixed by re-installing CocoaPods. For more info, see https://github.com/flutter/flutter/issues/14293.''';
3535

36-
const String outOfDatePodfileConsequence = '''
36+
const String outOfDateFrameworksPodfileConsequence = '''
3737
This can cause a mismatched version of Flutter to be embedded in your app, which may result in App Store submission rejection or crashes.
3838
If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/24641 for instructions.''';
3939

40+
const String outOfDatePluginsPodfileConsequence = '''
41+
This can cause issues if your application depends on plugins that do not support iOS.
42+
See https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms for details.
43+
If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/45197 for instructions.''';
44+
4045
const String cocoaPodsInstallInstructions = '''
4146
sudo gem install cocoapods''';
4247

@@ -375,25 +380,41 @@ class CocoaPods {
375380
}
376381
}
377382

378-
// Previously, the Podfile created a symlink to the cached artifacts engine framework
379-
// and installed the Flutter pod from that path. This could get out of sync with the copy
380-
// of the Flutter engine that was copied to ios/Flutter by the xcode_backend script.
381-
// It was possible for the symlink to point to a Debug version of the engine when the
382-
// Xcode build configuration was Release, which caused App Store submission rejections.
383-
//
384-
// Warn the user if they are still symlinking to the framework.
385383
void _warnIfPodfileOutOfDate(XcodeBasedProject xcodeProject) {
386384
if (xcodeProject is! IosProject) {
387385
return;
388386
}
387+
388+
// Previously, the Podfile created a symlink to the cached artifacts engine framework
389+
// and installed the Flutter pod from that path. This could get out of sync with the copy
390+
// of the Flutter engine that was copied to ios/Flutter by the xcode_backend script.
391+
// It was possible for the symlink to point to a Debug version of the engine when the
392+
// Xcode build configuration was Release, which caused App Store submission rejections.
393+
//
394+
// Warn the user if they are still symlinking to the framework.
389395
final Link flutterSymlink = _fileSystem.link(_fileSystem.path.join(
390-
xcodeProject.symlinks.path,
396+
(xcodeProject as IosProject).symlinks.path,
391397
'flutter',
392398
));
393399
if (flutterSymlink.existsSync()) {
394400
_logger.printError(
395401
'Warning: Podfile is out of date\n'
396-
'$outOfDatePodfileConsequence\n'
402+
'$outOfDateFrameworksPodfileConsequence\n'
403+
'To regenerate the Podfile, run:\n'
404+
'$podfileMigrationInstructions\n',
405+
emphasis: true,
406+
);
407+
return;
408+
}
409+
// Most of the pod and plugin parsing logic was moved from the Podfile
410+
// into the tool's podhelper.rb script. If the Podfile still references
411+
// the old parsed .flutter-plugins file, prompt the regeneration. Old line was:
412+
// plugin_pods = parse_KV_file('../.flutter-plugins')
413+
if (xcodeProject.podfile.existsSync() &&
414+
xcodeProject.podfile.readAsStringSync().contains('.flutter-plugins\'')) {
415+
_logger.printError(
416+
'Warning: Podfile is out of date\n'
417+
'$outOfDatePluginsPodfileConsequence\n'
397418
'To regenerate the Podfile, run:\n'
398419
'$podfileMigrationInstructions\n',
399420
emphasis: true,

packages/flutter_tools/lib/src/project.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,6 @@ abstract class XcodeBasedProject {
324324

325325
/// The CocoaPods 'Manifest.lock'.
326326
File get podManifestLock;
327-
328-
/// Directory containing symlinks to pub cache plugins source generated on `pod install`.
329-
Directory get symlinks;
330327
}
331328

332329
/// Represents the iOS sub-project of a Flutter project.
@@ -389,7 +386,6 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
389386
/// The default 'Info.plist' file of the host app. The developer can change this location in Xcode.
390387
File get defaultHostInfoPlist => hostAppRoot.childDirectory(_hostAppProjectName).childFile('Info.plist');
391388

392-
@override
393389
Directory get symlinks => _flutterLibRoot.childDirectory('.symlinks');
394390

395391
@override
@@ -970,9 +966,6 @@ class MacOSProject extends FlutterProjectPlatform implements XcodeBasedProject {
970966
@override
971967
Directory get xcodeWorkspace => _macOSDirectory.childDirectory('$_hostAppProjectName.xcworkspace');
972968

973-
@override
974-
Directory get symlinks => ephemeralDirectory.childDirectory('.symlinks');
975-
976969
/// The file where the Xcode build will write the name of the built app.
977970
///
978971
/// Ideally this will be replaced in the future with inspection of the Runner

packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ void main() {
355355
));
356356
});
357357

358-
testWithoutContext('prints warning, if Podfile is out of date', () async {
358+
testWithoutContext('prints warning, if Podfile creates the Flutter engine symlink', () async {
359359
pretendPodIsInstalled();
360360

361361
fs.file(fs.path.join('project', 'ios', 'Podfile'))
@@ -373,6 +373,20 @@ void main() {
373373
expect(logger.errorText, contains('Warning: Podfile is out of date'));
374374
});
375375

376+
testWithoutContext('prints warning, if Podfile parses .flutter-plugins', () async {
377+
pretendPodIsInstalled();
378+
379+
fs.file(fs.path.join('project', 'ios', 'Podfile'))
380+
..createSync()
381+
..writeAsStringSync('plugin_pods = parse_KV_file(\'../.flutter-plugins\')');
382+
383+
await cocoaPodsUnderTest.processPods(
384+
xcodeProject: projectUnderTest.ios,
385+
engineDir: 'engine/path',
386+
);
387+
expect(logger.errorText, contains('Warning: Podfile is out of date'));
388+
});
389+
376390
testWithoutContext('throws, if Podfile is missing.', () async {
377391
pretendPodIsInstalled();
378392
try {

0 commit comments

Comments
 (0)