Skip to content

Commit 3e265e9

Browse files
authored
Revert "Lazily initialise Xcode installation status (flutter#10945)" (flutter#10951)
This reverts commit bb8e2a7. Triggers a doctor failure on the Mac chromebots.
1 parent bb8e2a7 commit 3e265e9

File tree

1 file changed

+38
-42
lines changed
  • packages/flutter_tools/lib/src/ios

1 file changed

+38
-42
lines changed

packages/flutter_tools/lib/src/ios/mac.dart

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -80,58 +80,54 @@ class IMobileDevice {
8080
}
8181

8282
class Xcode {
83-
bool get isInstalledAndMeetsVersionCheck => isInstalled && xcodeVersionSatisfactory;
83+
Xcode() {
84+
_eulaSigned = false;
8485

85-
String _xcodeSelectPath;
86-
String get xcodeSelectPath {
87-
if (_xcodeSelectPath == null) {
88-
try {
89-
_xcodeSelectPath = runSync(<String>['/usr/bin/xcode-select', '--print-path'])?.trim();
90-
} on ProcessException {
91-
// Ignore: return null below.
86+
try {
87+
_xcodeSelectPath = runSync(<String>['xcode-select', '--print-path'])?.trim();
88+
if (_xcodeSelectPath == null || _xcodeSelectPath.isEmpty) {
89+
_isInstalled = false;
90+
return;
9291
}
92+
_isInstalled = true;
93+
94+
_xcodeVersionText = runSync(<String>['xcodebuild', '-version']).replaceAll('\n', ', ');
95+
96+
if (!xcodeVersionRegex.hasMatch(_xcodeVersionText)) {
97+
_isInstalled = false;
98+
} else {
99+
try {
100+
final ProcessResult result = processManager.runSync(<String>['/usr/bin/xcrun', 'clang']);
101+
102+
if (result.stdout != null && result.stdout.contains('license'))
103+
_eulaSigned = false;
104+
else if (result.stderr != null && result.stderr.contains('license'))
105+
_eulaSigned = false;
106+
else
107+
_eulaSigned = true;
108+
} catch (error) {
109+
_eulaSigned = false;
110+
}
111+
}
112+
} catch (error) {
113+
_isInstalled = false;
93114
}
94-
return _xcodeSelectPath;
95115
}
96116

97-
bool get isInstalled {
98-
if (xcodeSelectPath == null || xcodeSelectPath.isEmpty)
99-
return false;
100-
if (!xcodeVersionRegex.hasMatch(xcodeVersionText))
101-
return false;
102-
return true;
103-
}
117+
bool get isInstalledAndMeetsVersionCheck => isInstalled && xcodeVersionSatisfactory;
118+
119+
String _xcodeSelectPath;
120+
String get xcodeSelectPath => _xcodeSelectPath;
121+
122+
bool _isInstalled;
123+
bool get isInstalled => _isInstalled;
104124

105125
bool _eulaSigned;
106126
/// Has the EULA been signed?
107-
bool get eulaSigned {
108-
if (_eulaSigned == null) {
109-
try {
110-
final ProcessResult result = processManager.runSync(<String>['/usr/bin/xcrun', 'clang']);
111-
if (result.stdout != null && result.stdout.contains('license'))
112-
_eulaSigned = false;
113-
else if (result.stderr != null && result.stderr.contains('license'))
114-
_eulaSigned = false;
115-
else
116-
_eulaSigned = true;
117-
} on ProcessException {
118-
_eulaSigned = false;
119-
}
120-
}
121-
return _eulaSigned;
122-
}
127+
bool get eulaSigned => _eulaSigned;
123128

124129
String _xcodeVersionText;
125-
String get xcodeVersionText {
126-
if (_xcodeVersionText != null) {
127-
try {
128-
_xcodeVersionText = runSync(<String>['/usr/bin/xcodebuild', '-version']).replaceAll('\n', ', ');
129-
} on ProcessException {
130-
// Ignore: return null below.
131-
}
132-
}
133-
return _xcodeVersionText;
134-
}
130+
String get xcodeVersionText => _xcodeVersionText;
135131

136132
int _xcodeMajorVersion;
137133
int get xcodeMajorVersion => _xcodeMajorVersion;

0 commit comments

Comments
 (0)