Skip pod initialization if version >= 1.8.0. (#41491)
diff --git a/.cirrus.yml b/.cirrus.yml
index d18783a..738bf1b 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -414,7 +414,7 @@
print_date_script:
- date
install_cocoapods_script:
- - sudo gem install cocoapods -v 1.7.5 --no-document
+ - sudo gem install cocoapods --no-document
git_fetch_script:
- git clean -xfd
- git fetch origin
@@ -486,7 +486,7 @@
print_date_script:
- date
install_cocoapods_script:
- - sudo gem install cocoapods -v 1.7.5 --no-document
+ - sudo gem install cocoapods --no-document
git_fetch_script:
- git clean -xfd
- git fetch origin
diff --git a/dev/integration_tests/release_smoke_test/ios/Podfile b/dev/integration_tests/release_smoke_test/ios/Podfile
index 1de1efc..64ba749 100644
--- a/dev/integration_tests/release_smoke_test/ios/Podfile
+++ b/dev/integration_tests/release_smoke_test/ios/Podfile
@@ -1,6 +1,3 @@
-# Using a CDN with CocoaPods 1.7.2 or later can save a lot of time on pod installation, but it's experimental rather than the default.
-# source 'https://cdn.cocoapods.org/'
-
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
diff --git a/packages/flutter_tools/lib/src/macos/cocoapods.dart b/packages/flutter_tools/lib/src/macos/cocoapods.dart
index 26018b7..8cfac2a 100644
--- a/packages/flutter_tools/lib/src/macos/cocoapods.dart
+++ b/packages/flutter_tools/lib/src/macos/cocoapods.dart
@@ -35,12 +35,10 @@
This can usually be fixed by re-installing CocoaPods. For more info, see https://github.com/flutter/flutter/issues/14293.''';
const String cocoaPodsInstallInstructions = '''
- sudo gem install cocoapods
- pod setup''';
+ sudo gem install cocoapods''';
const String cocoaPodsUpgradeInstructions = '''
- sudo gem install cocoapods
- pod setup''';
+ sudo gem install cocoapods''';
CocoaPods get cocoaPods => context.get<CocoaPods>();
@@ -105,12 +103,20 @@
/// Whether CocoaPods ran 'pod setup' once where the costly pods' specs are
/// cloned.
///
+ /// Versions >= 1.8.0 do not require 'pod setup' and default to a CDN instead
+ /// of a locally cloned repository.
+ /// See http://blog.cocoapods.org/CocoaPods-1.8.0-beta/
+ ///
/// A user can override the default location via the CP_REPOS_DIR environment
/// variable.
///
/// See https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/config.rb#L138
/// for details of this variable.
- Future<bool> get isCocoaPodsInitialized {
+ Future<bool> get isCocoaPodsInitialized async {
+ final Version installedVersion = Version.parse(await cocoaPodsVersionText);
+ if (installedVersion != null && installedVersion >= Version.parse('1.8.0')) {
+ return true;
+ }
final String cocoapodsReposDir = platform.environment['CP_REPOS_DIR'] ?? fs.path.join(homeDirPath, '.cocoapods', 'repos');
return fs.isDirectory(fs.path.join(cocoapodsReposDir, 'master'));
}
diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc b/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc
index 1de1efc..64ba749 100644
--- a/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc
+++ b/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc
@@ -1,6 +1,3 @@
-# Using a CDN with CocoaPods 1.7.2 or later can save a lot of time on pod installation, but it's experimental rather than the default.
-# source 'https://cdn.cocoapods.org/'
-
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift b/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift
index e5e1440..e9286cb 100644
--- a/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift
+++ b/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift
@@ -1,6 +1,3 @@
-# Using a CDN with CocoaPods 1.7.2 or later can save a lot of time on pod installation, but it's experimental rather than the default.
-# source 'https://cdn.cocoapods.org/'
-
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-macos b/packages/flutter_tools/templates/cocoapods/Podfile-macos
index 129a34e..dc90941 100644
--- a/packages/flutter_tools/templates/cocoapods/Podfile-macos
+++ b/packages/flutter_tools/templates/cocoapods/Podfile-macos
@@ -1,6 +1,3 @@
-# Using a CDN with CocoaPods 1.7.2 or later can save a lot of time on pod installation, but it's experimental rather than the default.
-# source 'https://cdn.cocoapods.org/'
-
platform :osx, '10.11'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
diff --git a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
index c82c4cf..57ca558 100644
--- a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
+++ b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
@@ -160,6 +160,16 @@
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
});
+
+ testUsingContext('detects initialized over 1.8.0', () async {
+ pretendPodIsInstalled();
+ pretendPodVersionIs('1.8.0');
+ expect(await cocoaPodsUnderTest.isCocoaPodsInitialized, isTrue);
+ }, overrides: <Type, Generator>{
+ ProcessManager: () => mockProcessManager,
+ Platform: () => FakePlatform(),
+ FileSystem: () => fs,
+ });
});
group('Setup Podfile', () {