Add Podfile migration warning to support federated plugins (#59201)
This commit is contained in:
parent
97dc7eee57
commit
0093c6a4c6
@ -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,6 +380,11 @@ class CocoaPods {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _warnIfPodfileOutOfDate(XcodeBasedProject xcodeProject) {
|
||||||
|
if (xcodeProject is! IosProject) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Previously, the Podfile created a symlink to the cached artifacts engine framework
|
// 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
|
// 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.
|
// of the Flutter engine that was copied to ios/Flutter by the xcode_backend script.
|
||||||
@ -382,18 +392,29 @@ class CocoaPods {
|
|||||||
// Xcode build configuration was Release, which caused App Store submission rejections.
|
// Xcode build configuration was Release, which caused App Store submission rejections.
|
||||||
//
|
//
|
||||||
// Warn the user if they are still symlinking to the framework.
|
// Warn the user if they are still symlinking to the framework.
|
||||||
void _warnIfPodfileOutOfDate(XcodeBasedProject xcodeProject) {
|
|
||||||
if (xcodeProject is! IosProject) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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 {
|
|||||||
|
|
||||||
/// 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 {
|
|||||||
/// 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 {
|
|||||||
@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() {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
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() {
|
|||||||
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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user