From 1eb1e2226bef1121103d5659951e297623177ffc Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 30 Sep 2019 13:14:42 -0700 Subject: [PATCH] Skip pod initialization if version >= 1.8.0. (#41491) --- .cirrus.yml | 4 ++-- .../release_smoke_test/ios/Podfile | 3 --- .../flutter_tools/lib/src/macos/cocoapods.dart | 16 +++++++++++----- .../templates/cocoapods/Podfile-ios-objc | 3 --- .../templates/cocoapods/Podfile-ios-swift | 3 --- .../templates/cocoapods/Podfile-macos | 3 --- .../test/general.shard/macos/cocoapods_test.dart | 10 ++++++++++ 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index d18783afe6..738bf1b72c 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -414,7 +414,7 @@ task: 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 @@ task: 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 1de1efcd2e..64ba7492ea 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 26018b7fd7..8cfac2a2c4 100644 --- a/packages/flutter_tools/lib/src/macos/cocoapods.dart +++ b/packages/flutter_tools/lib/src/macos/cocoapods.dart @@ -35,12 +35,10 @@ const String brokenCocoaPodsConsequence = ''' 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(); @@ -105,12 +103,20 @@ class CocoaPods { /// 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 get isCocoaPodsInitialized { + Future 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 1de1efcd2e..64ba7492ea 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 e5e1440b02..e9286cbac1 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 129a34eda3..dc90941dc9 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 c82c4cfd04..57ca5589e2 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 @@ void main() { }, overrides: { ProcessManager: () => mockProcessManager, }); + + testUsingContext('detects initialized over 1.8.0', () async { + pretendPodIsInstalled(); + pretendPodVersionIs('1.8.0'); + expect(await cocoaPodsUnderTest.isCocoaPodsInitialized, isTrue); + }, overrides: { + ProcessManager: () => mockProcessManager, + Platform: () => FakePlatform(), + FileSystem: () => fs, + }); }); group('Setup Podfile', () {