Always embed Flutter.framework build mode version from Xcode configuration (#42029)

This commit is contained in:
Jenn Magder
2019-10-15 15:33:55 -07:00
committed by GitHub
parent ad1d67e0a1
commit 357d02c87b
20 changed files with 424 additions and 210 deletions

View File

@@ -4,6 +4,7 @@
import 'dart:async';
import 'package:file/file.dart';
import 'package:meta/meta.dart';
import '../base/common.dart';
@@ -34,12 +35,19 @@ 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 usually be fixed by re-installing CocoaPods. For more info, see https://github.com/flutter/flutter/issues/14293.''';
const String outOfDatePodfileConsequence = '''
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.''';
const String cocoaPodsInstallInstructions = '''
sudo gem install cocoapods''';
const String cocoaPodsUpgradeInstructions = '''
sudo gem install cocoapods''';
const String podfileMigrationInstructions = '''
rm ios/Podfile''';
CocoaPods get cocoaPods => context.get<CocoaPods>();
/// Result of evaluating the CocoaPods installation.
@@ -131,13 +139,15 @@ class CocoaPods {
if (!xcodeProject.podfile.existsSync()) {
throwToolExit('Podfile missing');
}
bool podsProcessed = false;
if (await _checkPodCondition()) {
if (_shouldRunPodInstall(xcodeProject, dependenciesChanged)) {
await _runPodInstall(xcodeProject, engineDir);
return true;
podsProcessed = true;
}
_warnIfPodfileOutOfDate(xcodeProject);
}
return false;
return podsProcessed;
}
/// Make sure the CocoaPods tools are in the right states.
@@ -291,7 +301,6 @@ class CocoaPods {
<String>['pod', 'install', '--verbose'],
workingDirectory: fs.path.dirname(xcodeProject.podfile.path),
environment: <String, String>{
// For backward compatibility with previously created Podfile only.
'FLUTTER_FRAMEWORK_DIR': engineDirectory,
// See https://github.com/flutter/flutter/issues/10873.
// CocoaPods analytics adds a lot of latency.
@@ -326,4 +335,30 @@ 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) {
if (xcodeProject is! IosProject) {
return;
}
final Link flutterSymlink = fs.link(fs.path.join(
xcodeProject.symlinks.path,
'flutter',
));
if (flutterSymlink.existsSync()) {
printError(
'Warning: Podfile is out of date\n'
'$outOfDatePodfileConsequence\n'
'To regenerate the Podfile, run:\n'
'$podfileMigrationInstructions\n',
emphasis: true,
);
}
}
}

View File

@@ -288,6 +288,9 @@ abstract class XcodeBasedProject {
/// True if the host app project is using Swift.
Future<bool> get isSwift;
/// Directory containing symlinks to pub cache plugins source generated on `pod install`.
Directory get symlinks;
}
/// Represents the iOS sub-project of a Flutter project.
@@ -350,6 +353,9 @@ class IosProject implements XcodeBasedProject {
/// The 'Info.plist' file of the host app.
File get hostInfoPlist => hostAppRoot.childDirectory(_hostAppBundleName).childFile('Info.plist');
@override
Directory get symlinks => _flutterLibRoot.childDirectory('.symlinks');
@override
Directory get xcodeProject => hostAppRoot.childDirectory('$_hostAppBundleName.xcodeproj');
@@ -742,6 +748,9 @@ class MacOSProject implements XcodeBasedProject {
@override
Directory get xcodeWorkspace => _macOSDirectory.childDirectory('$_hostAppBundleName.xcworkspace');
@override
Directory get symlinks => ephemeralDirectory.childDirectory('.symlinks');
@override
Future<bool> get isSwift async => true;