Unverified Commit 0093c6a4 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Add Podfile migration warning to support federated plugins (#59201)

parent 97dc7eee
...@@ -33,10 +33,15 @@ const String brokenCocoaPodsConsequence = ''' ...@@ -33,10 +33,15 @@ const String brokenCocoaPodsConsequence = '''
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it. This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods. For more info, see https://github.com/flutter/flutter/issues/14293.'''; This can usually be fixed by re-installing CocoaPods. For more info, see https://github.com/flutter/flutter/issues/14293.''';
const String outOfDatePodfileConsequence = ''' const String outOfDateFrameworksPodfileConsequence = '''
This can cause a mismatched version of Flutter to be embedded in your app, which may result in App Store submission rejection or crashes. This can cause a mismatched version of Flutter to be embedded in your app, which may result in App Store submission rejection or crashes.
If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/24641 for instructions.'''; If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/24641 for instructions.''';
const String outOfDatePluginsPodfileConsequence = '''
This can cause issues if your application depends on plugins that do not support iOS.
See https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms for details.
If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/45197 for instructions.''';
const String cocoaPodsInstallInstructions = ''' const String cocoaPodsInstallInstructions = '''
sudo gem install cocoapods'''; sudo gem install cocoapods''';
...@@ -375,25 +380,41 @@ class CocoaPods { ...@@ -375,25 +380,41 @@ class CocoaPods {
} }
} }
// Previously, the Podfile created a symlink to the cached artifacts engine framework
// and installed the Flutter pod from that path. This could get out of sync with the copy
// of the Flutter engine that was copied to ios/Flutter by the xcode_backend script.
// It was possible for the symlink to point to a Debug version of the engine when the
// Xcode build configuration was Release, which caused App Store submission rejections.
//
// Warn the user if they are still symlinking to the framework.
void _warnIfPodfileOutOfDate(XcodeBasedProject xcodeProject) { void _warnIfPodfileOutOfDate(XcodeBasedProject xcodeProject) {
if (xcodeProject is! IosProject) { if (xcodeProject is! IosProject) {
return; return;
} }
// Previously, the Podfile created a symlink to the cached artifacts engine framework
// and installed the Flutter pod from that path. This could get out of sync with the copy
// of the Flutter engine that was copied to ios/Flutter by the xcode_backend script.
// It was possible for the symlink to point to a Debug version of the engine when the
// Xcode build configuration was Release, which caused App Store submission rejections.
//
// Warn the user if they are still symlinking to the framework.
final Link flutterSymlink = _fileSystem.link(_fileSystem.path.join( final Link flutterSymlink = _fileSystem.link(_fileSystem.path.join(
xcodeProject.symlinks.path, (xcodeProject as IosProject).symlinks.path,
'flutter', 'flutter',
)); ));
if (flutterSymlink.existsSync()) { if (flutterSymlink.existsSync()) {
_logger.printError( _logger.printError(
'Warning: Podfile is out of date\n' 'Warning: Podfile is out of date\n'
'$outOfDatePodfileConsequence\n' '$outOfDateFrameworksPodfileConsequence\n'
'To regenerate the Podfile, run:\n'
'$podfileMigrationInstructions\n',
emphasis: true,
);
return;
}
// Most of the pod and plugin parsing logic was moved from the Podfile
// into the tool's podhelper.rb script. If the Podfile still references
// the old parsed .flutter-plugins file, prompt the regeneration. Old line was:
// plugin_pods = parse_KV_file('../.flutter-plugins')
if (xcodeProject.podfile.existsSync() &&
xcodeProject.podfile.readAsStringSync().contains('.flutter-plugins\'')) {
_logger.printError(
'Warning: Podfile is out of date\n'
'$outOfDatePluginsPodfileConsequence\n'
'To regenerate the Podfile, run:\n' 'To regenerate the Podfile, run:\n'
'$podfileMigrationInstructions\n', '$podfileMigrationInstructions\n',
emphasis: true, emphasis: true,
......
...@@ -324,9 +324,6 @@ abstract class XcodeBasedProject { ...@@ -324,9 +324,6 @@ abstract class XcodeBasedProject {
/// The CocoaPods 'Manifest.lock'. /// The CocoaPods 'Manifest.lock'.
File get podManifestLock; File get podManifestLock;
/// Directory containing symlinks to pub cache plugins source generated on `pod install`.
Directory get symlinks;
} }
/// Represents the iOS sub-project of a Flutter project. /// Represents the iOS sub-project of a Flutter project.
...@@ -389,7 +386,6 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject { ...@@ -389,7 +386,6 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
/// The default 'Info.plist' file of the host app. The developer can change this location in Xcode. /// The default 'Info.plist' file of the host app. The developer can change this location in Xcode.
File get defaultHostInfoPlist => hostAppRoot.childDirectory(_hostAppProjectName).childFile('Info.plist'); File get defaultHostInfoPlist => hostAppRoot.childDirectory(_hostAppProjectName).childFile('Info.plist');
@override
Directory get symlinks => _flutterLibRoot.childDirectory('.symlinks'); Directory get symlinks => _flutterLibRoot.childDirectory('.symlinks');
@override @override
...@@ -970,9 +966,6 @@ class MacOSProject extends FlutterProjectPlatform implements XcodeBasedProject { ...@@ -970,9 +966,6 @@ class MacOSProject extends FlutterProjectPlatform implements XcodeBasedProject {
@override @override
Directory get xcodeWorkspace => _macOSDirectory.childDirectory('$_hostAppProjectName.xcworkspace'); Directory get xcodeWorkspace => _macOSDirectory.childDirectory('$_hostAppProjectName.xcworkspace');
@override
Directory get symlinks => ephemeralDirectory.childDirectory('.symlinks');
/// The file where the Xcode build will write the name of the built app. /// The file where the Xcode build will write the name of the built app.
/// ///
/// Ideally this will be replaced in the future with inspection of the Runner /// Ideally this will be replaced in the future with inspection of the Runner
......
...@@ -355,7 +355,7 @@ void main() { ...@@ -355,7 +355,7 @@ void main() {
)); ));
}); });
testWithoutContext('prints warning, if Podfile is out of date', () async { testWithoutContext('prints warning, if Podfile creates the Flutter engine symlink', () async {
pretendPodIsInstalled(); pretendPodIsInstalled();
fs.file(fs.path.join('project', 'ios', 'Podfile')) fs.file(fs.path.join('project', 'ios', 'Podfile'))
...@@ -373,6 +373,20 @@ void main() { ...@@ -373,6 +373,20 @@ void main() {
expect(logger.errorText, contains('Warning: Podfile is out of date')); expect(logger.errorText, contains('Warning: Podfile is out of date'));
}); });
testWithoutContext('prints warning, if Podfile parses .flutter-plugins', () async {
pretendPodIsInstalled();
fs.file(fs.path.join('project', 'ios', 'Podfile'))
..createSync()
..writeAsStringSync('plugin_pods = parse_KV_file(\'../.flutter-plugins\')');
await cocoaPodsUnderTest.processPods(
xcodeProject: projectUnderTest.ios,
engineDir: 'engine/path',
);
expect(logger.errorText, contains('Warning: Podfile is out of date'));
});
testWithoutContext('throws, if Podfile is missing.', () async { testWithoutContext('throws, if Podfile is missing.', () async {
pretendPodIsInstalled(); pretendPodIsInstalled();
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment