Add recommended Xcode version to doctor (#73808)
This commit is contained in:
@@ -139,8 +139,9 @@ class UserMessages {
|
||||
|
||||
// Messages used in XcodeValidator
|
||||
String xcodeLocation(String location) => 'Xcode at $location';
|
||||
String xcodeOutdated(int versionMajor, int versionMinor, int versionPatch) =>
|
||||
'Flutter requires a minimum Xcode version of $versionMajor.$versionMinor.$versionPatch.\n'
|
||||
|
||||
String xcodeOutdated(String currentVersion, String recommendedVersion) =>
|
||||
'Xcode $currentVersion out of date ($recommendedVersion is recommended).\n'
|
||||
'Download the latest version or update via the Mac App Store.';
|
||||
String get xcodeEula => "Xcode end user license agreement not signed; open Xcode or run the command 'sudo xcodebuild -license'.";
|
||||
String get xcodeMissingSimct =>
|
||||
|
||||
@@ -637,7 +637,7 @@ class XcodeBuildExecution {
|
||||
final Map<String, String> buildSettings;
|
||||
}
|
||||
|
||||
const String _xcodeRequirement = 'Xcode $kXcodeRequiredVersionMajor.$kXcodeRequiredVersionMinor.$kXcodeRequiredVersionPatch or greater is required to develop for iOS.';
|
||||
final String _xcodeRequirement = 'Xcode $xcodeRequiredVersion or greater is required to develop for iOS.';
|
||||
|
||||
bool _checkXcodeVersion() {
|
||||
if (!globals.platform.isMacOS) {
|
||||
@@ -647,7 +647,7 @@ bool _checkXcodeVersion() {
|
||||
globals.printError('Cannot find "xcodebuild". $_xcodeRequirement');
|
||||
return false;
|
||||
}
|
||||
if (!globals.xcode.isVersionSatisfactory) {
|
||||
if (!globals.xcode.isRequiredVersionSatisfactory) {
|
||||
globals.printError('Found "${globals.xcodeProjectInterpreter.versionText}". $_xcodeRequirement');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../base/common.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/logger.dart';
|
||||
import '../../base/project_migrator.dart';
|
||||
import '../../base/version.dart';
|
||||
import '../../macos/xcode.dart';
|
||||
import '../../project.dart';
|
||||
import '../../reporting/reporting.dart';
|
||||
@@ -99,7 +100,7 @@ class RemoveFrameworkLinkAndEmbeddingMigration extends ProjectMigrator {
|
||||
if (line.contains('/* App.framework ') || line.contains('/* Flutter.framework ')) {
|
||||
// Print scary message if the user is on Xcode 11.4 or greater, or if Xcode isn't installed.
|
||||
final bool xcodeIsInstalled = _xcode.isInstalled;
|
||||
if(!xcodeIsInstalled || (_xcode.majorVersion > 11 || (_xcode.majorVersion == 11 && _xcode.minorVersion >= 4))) {
|
||||
if(!xcodeIsInstalled || _xcode.currentVersion >= Version(11, 4, 0)) {
|
||||
UsageEvent('ios-migration', 'remove-frameworks', label: 'failure', flutterUsage: _usage).send();
|
||||
throwToolExit('Your Xcode project requires migration. See https://flutter.dev/docs/development/ios-project-migration for details.');
|
||||
}
|
||||
|
||||
@@ -73,7 +73,6 @@ class IOSSimulatorUtils {
|
||||
name: device.name,
|
||||
simControl: _simControl,
|
||||
simulatorCategory: device.category,
|
||||
xcode: _xcode,
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
@@ -309,9 +308,7 @@ class IOSSimulator extends Device {
|
||||
this.name,
|
||||
this.simulatorCategory,
|
||||
@required SimControl simControl,
|
||||
@required Xcode xcode,
|
||||
}) : _simControl = simControl,
|
||||
_xcode = xcode,
|
||||
super(
|
||||
id,
|
||||
category: Category.mobile,
|
||||
@@ -325,7 +322,6 @@ class IOSSimulator extends Device {
|
||||
final String simulatorCategory;
|
||||
|
||||
final SimControl _simControl;
|
||||
final Xcode _xcode;
|
||||
|
||||
@override
|
||||
DevFSWriter createDevFSWriter(covariant ApplicationPackage app, String userIdentifier) {
|
||||
@@ -610,12 +606,8 @@ class IOSSimulator extends Device {
|
||||
}
|
||||
}
|
||||
|
||||
bool get _xcodeVersionSupportsScreenshot {
|
||||
return _xcode.majorVersion > 8 || (_xcode.majorVersion == 8 && _xcode.minorVersion >= 2);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get supportsScreenshot => _xcodeVersionSupportsScreenshot;
|
||||
bool get supportsScreenshot => true;
|
||||
|
||||
@override
|
||||
Future<void> takeScreenshot(File outputFile) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/version.dart';
|
||||
import '../build_info.dart';
|
||||
import '../cache.dart';
|
||||
import '../convert.dart';
|
||||
@@ -25,9 +26,8 @@ import '../ios/mac.dart';
|
||||
import '../ios/xcodeproj.dart';
|
||||
import '../reporting/reporting.dart';
|
||||
|
||||
const int kXcodeRequiredVersionMajor = 11;
|
||||
const int kXcodeRequiredVersionMinor = 0;
|
||||
const int kXcodeRequiredVersionPatch = 0;
|
||||
Version get xcodeRequiredVersion => Version(11, 0, 0, text: '11.0');
|
||||
Version get xcodeRecommendedVersion => Version(12, 0, 1, text: '12.0.1');
|
||||
|
||||
/// SDK name passed to `xcrun --sdk`. Corresponds to undocumented Xcode
|
||||
/// SUPPORTED_PLATFORMS values.
|
||||
@@ -60,7 +60,7 @@ class Xcode {
|
||||
final FileSystem _fileSystem;
|
||||
final XcodeProjectInterpreter _xcodeProjectInterpreter;
|
||||
|
||||
bool get isInstalledAndMeetsVersionCheck => _platform.isMacOS && isInstalled && isVersionSatisfactory;
|
||||
bool get isInstalledAndMeetsVersionCheck => _platform.isMacOS && isInstalled && isRequiredVersionSatisfactory;
|
||||
|
||||
String _xcodeSelectPath;
|
||||
String get xcodeSelectPath {
|
||||
@@ -85,9 +85,13 @@ class Xcode {
|
||||
return _xcodeProjectInterpreter.isInstalled;
|
||||
}
|
||||
|
||||
int get majorVersion => _xcodeProjectInterpreter.majorVersion;
|
||||
int get minorVersion => _xcodeProjectInterpreter.minorVersion;
|
||||
int get patchVersion => _xcodeProjectInterpreter.patchVersion;
|
||||
Version get currentVersion => Version(
|
||||
_xcodeProjectInterpreter.majorVersion,
|
||||
_xcodeProjectInterpreter.minorVersion,
|
||||
_xcodeProjectInterpreter.patchVersion,
|
||||
text:
|
||||
'${_xcodeProjectInterpreter.majorVersion}.${_xcodeProjectInterpreter.minorVersion}.${_xcodeProjectInterpreter.patchVersion}',
|
||||
);
|
||||
|
||||
String get versionText => _xcodeProjectInterpreter.versionText;
|
||||
|
||||
@@ -132,20 +136,18 @@ class Xcode {
|
||||
return _isSimctlInstalled;
|
||||
}
|
||||
|
||||
bool get isVersionSatisfactory {
|
||||
bool get isRequiredVersionSatisfactory {
|
||||
if (!_xcodeProjectInterpreter.isInstalled) {
|
||||
return false;
|
||||
}
|
||||
if (majorVersion > kXcodeRequiredVersionMajor) {
|
||||
return true;
|
||||
return currentVersion >= xcodeRequiredVersion;
|
||||
}
|
||||
|
||||
bool get isRecommendedVersionSatisfactory {
|
||||
if (!_xcodeProjectInterpreter.isInstalled) {
|
||||
return false;
|
||||
}
|
||||
if (majorVersion == kXcodeRequiredVersionMajor) {
|
||||
if (minorVersion == kXcodeRequiredVersionMinor) {
|
||||
return patchVersion >= kXcodeRequiredVersionPatch;
|
||||
}
|
||||
return minorVersion >= kXcodeRequiredVersionMinor;
|
||||
}
|
||||
return false;
|
||||
return currentVersion >= xcodeRecommendedVersion;
|
||||
}
|
||||
|
||||
/// See [XcodeProjectInterpreter.xcrunCommand].
|
||||
|
||||
@@ -29,18 +29,20 @@ class XcodeValidator extends DoctorValidator {
|
||||
xcodeStatus = ValidationType.installed;
|
||||
|
||||
messages.add(ValidationMessage(_userMessages.xcodeLocation(_xcode.xcodeSelectPath)));
|
||||
|
||||
xcodeVersionInfo = _xcode.versionText;
|
||||
if (xcodeVersionInfo.contains(',')) {
|
||||
xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(','));
|
||||
}
|
||||
messages.add(ValidationMessage(_xcode.versionText));
|
||||
|
||||
if (!_xcode.isInstalledAndMeetsVersionCheck) {
|
||||
xcodeStatus = ValidationType.partial;
|
||||
messages.add(ValidationMessage.error(
|
||||
_userMessages.xcodeOutdated(kXcodeRequiredVersionMajor, kXcodeRequiredVersionMinor, kXcodeRequiredVersionPatch)
|
||||
));
|
||||
messages.add(ValidationMessage.error(_userMessages.xcodeOutdated(
|
||||
_xcode.currentVersion.toString(),
|
||||
xcodeRecommendedVersion.toString(),
|
||||
)));
|
||||
} else if (!_xcode.isRecommendedVersionSatisfactory) {
|
||||
xcodeStatus = ValidationType.partial;
|
||||
messages.add(ValidationMessage.hint(_userMessages.xcodeOutdated(
|
||||
_xcode.currentVersion.toString(),
|
||||
xcodeRecommendedVersion.toString(),
|
||||
)));
|
||||
}
|
||||
|
||||
if (!_xcode.eulaSigned) {
|
||||
|
||||
Reference in New Issue
Block a user