Skip to content

Commit 23f5fbc

Browse files
authored
Update CocoaPods minimum version to 1.9 (flutter#71170)
1 parent 9f7e785 commit 23f5fbc

File tree

5 files changed

+8
-70
lines changed

5 files changed

+8
-70
lines changed

packages/flutter_tools/lib/src/base/user_messages.dart

-6
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ class UserMessages {
160160

161161
// Messages used in CocoaPodsValidator
162162
String cocoaPodsVersion(String version) => 'CocoaPods version $version';
163-
String cocoaPodsUninitialized(String consequence) =>
164-
'CocoaPods installed but not initialized.\n'
165-
'$consequence\n'
166-
'To initialize CocoaPods, run:\n'
167-
' pod setup\n'
168-
"once to finalize CocoaPods' installation.";
169163
String cocoaPodsMissing(String consequence, String installInstructions) =>
170164
'CocoaPods not installed.\n'
171165
'$consequence\n'

packages/flutter_tools/lib/src/macos/cocoapods.dart

+2-39
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@ class CocoaPods {
8989
_processManager = processManager,
9090
_xcodeProjectInterpreter = xcodeProjectInterpreter,
9191
_logger = logger,
92-
_platform = platform,
9392
_artifacts = artifacts,
9493
_usage = usage,
9594
_processUtils = ProcessUtils(processManager: processManager, logger: logger),
96-
_fileSystemUtils = FileSystemUtils(fileSystem: fileSystem, platform: platform),
9795
_operatingSystemUtils = OperatingSystemUtils(
9896
fileSystem: fileSystem,
9997
logger: logger,
@@ -103,19 +101,17 @@ class CocoaPods {
103101

104102
final FileSystem _fileSystem;
105103
final ProcessManager _processManager;
106-
final FileSystemUtils _fileSystemUtils;
107104
final ProcessUtils _processUtils;
108105
final OperatingSystemUtils _operatingSystemUtils;
109106
final XcodeProjectInterpreter _xcodeProjectInterpreter;
110107
final Logger _logger;
111-
final Platform _platform;
112108
final Artifacts _artifacts;
113109
final Usage _usage;
114110

115111
Future<String> _versionText;
116112

117-
String get cocoaPodsMinimumVersion => '1.6.0';
118-
String get cocoaPodsRecommendedVersion => '1.9.0';
113+
String get cocoaPodsMinimumVersion => '1.9.0';
114+
String get cocoaPodsRecommendedVersion => '1.10.0';
119115

120116
Future<bool> get isInstalled =>
121117
_processUtils.exitsHappy(<String>['which', 'pod']);
@@ -157,28 +153,6 @@ class CocoaPods {
157153
}
158154
}
159155

160-
/// Whether CocoaPods ran 'pod setup' once where the costly pods' specs are
161-
/// cloned.
162-
///
163-
/// Versions >= 1.8.0 do not require 'pod setup' and default to a CDN instead
164-
/// of a locally cloned repository.
165-
/// See http://blog.cocoapods.org/CocoaPods-1.8.0-beta/
166-
///
167-
/// A user can override the default location via the CP_REPOS_DIR environment
168-
/// variable.
169-
///
170-
/// See https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/config.rb#L138
171-
/// for details of this variable.
172-
Future<bool> get isCocoaPodsInitialized async {
173-
final Version installedVersion = Version.parse(await cocoaPodsVersionText);
174-
if (installedVersion != null && installedVersion >= Version.parse('1.8.0')) {
175-
return true;
176-
}
177-
final String cocoapodsReposDir = _platform.environment['CP_REPOS_DIR']
178-
?? _fileSystem.path.join(_fileSystemUtils.homeDirPath, '.cocoapods', 'repos');
179-
return _fileSystem.isDirectory(_fileSystem.path.join(cocoapodsReposDir, 'master'));
180-
}
181-
182156
Future<bool> processPods({
183157
@required XcodeBasedProject xcodeProject,
184158
@required BuildMode buildMode,
@@ -246,17 +220,6 @@ class CocoaPods {
246220
case CocoaPodsStatus.recommended:
247221
break;
248222
}
249-
if (!await isCocoaPodsInitialized) {
250-
_logger.printError(
251-
'Warning: CocoaPods installed but not initialized. Skipping pod install.\n'
252-
'$noCocoaPodsConsequence\n'
253-
'To initialize CocoaPods, run:\n'
254-
' pod setup\n'
255-
"once to finalize CocoaPods' installation.",
256-
emphasis: true,
257-
);
258-
return false;
259-
}
260223

261224
return true;
262225
}

packages/flutter_tools/lib/src/macos/cocoapods_validator.dart

+1-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ class CocoaPodsValidator extends DoctorValidator {
3030

3131
ValidationType status = ValidationType.installed;
3232
if (cocoaPodsStatus == CocoaPodsStatus.recommended) {
33-
if (await _cocoaPods.isCocoaPodsInitialized) {
34-
messages.add(ValidationMessage(_userMessages.cocoaPodsVersion(await _cocoaPods.cocoaPodsVersionText)));
35-
} else {
36-
status = ValidationType.partial;
37-
messages.add(ValidationMessage.error(_userMessages.cocoaPodsUninitialized(noCocoaPodsConsequence)));
38-
}
33+
messages.add(ValidationMessage(_userMessages.cocoaPodsVersion(await _cocoaPods.cocoaPodsVersionText)));
3934
} else {
4035
if (cocoaPodsStatus == CocoaPodsStatus.notInstalled) {
4136
status = ValidationType.missing;

packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart

+5-11
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void main() {
8080
xcodeProjectInterpreter: mockXcodeProjectInterpreter,
8181
usage: usage,
8282
);
83-
pretendPodVersionIs('1.9.0');
83+
pretendPodVersionIs('1.10.0');
8484
fileSystem.file(fileSystem.path.join(
8585
Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-objc',
8686
))
@@ -177,33 +177,27 @@ void main() {
177177

178178
testWithoutContext('detects below minimum version', () async {
179179
pretendPodIsInstalled();
180-
pretendPodVersionIs('1.5.0');
180+
pretendPodVersionIs('1.6.0');
181181
expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.belowMinimumVersion);
182182
});
183183

184184
testWithoutContext('detects below recommended version', () async {
185185
pretendPodIsInstalled();
186-
pretendPodVersionIs('1.6.0');
186+
pretendPodVersionIs('1.9.0');
187187
expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.belowRecommendedVersion);
188188
});
189189

190190
testWithoutContext('detects at recommended version', () async {
191191
pretendPodIsInstalled();
192-
pretendPodVersionIs('1.9.0');
192+
pretendPodVersionIs('1.10.0');
193193
expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.recommended);
194194
});
195195

196196
testWithoutContext('detects above recommended version', () async {
197197
pretendPodIsInstalled();
198-
pretendPodVersionIs('1.9.1');
198+
pretendPodVersionIs('1.10.1');
199199
expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.recommended);
200200
});
201-
202-
testWithoutContext('detects initialized over 1.8.0', () async {
203-
pretendPodIsInstalled();
204-
pretendPodVersionIs('1.8.0');
205-
expect(await cocoaPodsUnderTest.isCocoaPodsInitialized, isTrue);
206-
});
207201
});
208202

209203
group('Setup Podfile', () {

packages/flutter_tools/test/general.shard/macos/cocoapods_validator_test.dart

-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ void main() {
1818
cocoaPods = MockCocoaPods();
1919
when(cocoaPods.evaluateCocoaPodsInstallation)
2020
.thenAnswer((_) async => CocoaPodsStatus.recommended);
21-
when(cocoaPods.isCocoaPodsInitialized).thenAnswer((_) async => true);
2221
when(cocoaPods.cocoaPodsVersionText).thenAnswer((_) async => '1.8.0');
2322
});
2423

@@ -44,13 +43,6 @@ void main() {
4443
expect(result.type, ValidationType.partial);
4544
});
4645

47-
testWithoutContext('Emits partial status when CocoaPods is not initialized', () async {
48-
when(cocoaPods.isCocoaPodsInitialized).thenAnswer((_) async => false);
49-
final CocoaPodsValidator workflow = CocoaPodsValidator(cocoaPods, UserMessages());
50-
final ValidationResult result = await workflow.validate();
51-
expect(result.type, ValidationType.partial);
52-
});
53-
5446
testWithoutContext('Emits partial status when CocoaPods version is too low', () async {
5547
when(cocoaPods.evaluateCocoaPodsInstallation)
5648
.thenAnswer((_) async => CocoaPodsStatus.belowRecommendedVersion);

0 commit comments

Comments
 (0)