From 0efc06ca4598b3794a29c6c9caa339a66fba3cbd Mon Sep 17 00:00:00 2001 From: xster Date: Wed, 17 Jan 2018 18:17:04 -0800 Subject: [PATCH] Disable cocoapods stats in Podfile template (#13945) --- examples/flutter_gallery/ios/Podfile | 56 ++++++++++++------- .../templates/cocoapods/Podfile-objc | 3 + .../templates/cocoapods/Podfile-swift | 3 + 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/examples/flutter_gallery/ios/Podfile b/examples/flutter_gallery/ios/Podfile index 74b3de0649..cfee435775 100644 --- a/examples/flutter_gallery/ios/Podfile +++ b/examples/flutter_gallery/ios/Podfile @@ -1,32 +1,48 @@ # Uncomment this line to define a global platform for your project # platform :ios, '9.0' -if ENV['FLUTTER_FRAMEWORK_DIR'] == nil - abort('Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework') -end +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' -target 'Runner' do - use_frameworks! - - # Pods for Runner - - # Flutter Pods - pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR'] - - if File.exists? '../.flutter-plugins' - flutter_root = File.expand_path('..') - File.foreach('../.flutter-plugins') { |line| - plugin = line.split(pattern='=') +def parse_KV_file(file,seperator='=') + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return []; + end + pods_ary = [] + skip_line_start_symbols = ["#", "/"] + File.foreach(file_abs_path) { |line| + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } + plugin = line.split(pattern=seperator) if plugin.length == 2 - name = plugin[0].strip() + podname = plugin[0].strip() path = plugin[1].strip() - resolved_path = File.expand_path("#{path}/ios", flutter_root) - pod name, :path => resolved_path + podpath = File.expand_path("#{path}", file_abs_path) + pods_ary.push({:name => podname,:path=>podpath}); else puts "Invalid plugin specification: #{line}" end - } + } + return pods_ary +end + +target 'Runner' do + # Flutter Pods + generated_xcode_build_settings = parse_KV_file("./Flutter/Generated.xcconfig") + if generated_xcode_build_settings.empty? + puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter build or flutter run is executed once first." end + generated_xcode_build_settings.map{ |p| + if p[:name]=='FLUTTER_FRAMEWORK_DIR' + pod 'Flutter', :path => p[:path] + end + } + + # Plugin Pods + plugin_pods = parse_KV_file("../.flutter-plugins") + plugin_pods.map{ |p| + pod p[:name], :path => File.expand_path("ios",p[:path]) + } end post_install do |installer| @@ -35,4 +51,4 @@ post_install do |installer| config.build_settings['ENABLE_BITCODE'] = 'NO' end end -end +end \ No newline at end of file diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-objc b/packages/flutter_tools/templates/cocoapods/Podfile-objc index 8fe8720f9b..cfee435775 100644 --- a/packages/flutter_tools/templates/cocoapods/Podfile-objc +++ b/packages/flutter_tools/templates/cocoapods/Podfile-objc @@ -1,6 +1,9 @@ # Uncomment this line to define a global platform for your project # platform :ios, '9.0' +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + def parse_KV_file(file,seperator='=') file_abs_path = File.expand_path(file) if !File.exists? file_abs_path diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-swift b/packages/flutter_tools/templates/cocoapods/Podfile-swift index 04016c5a82..3b57402e6a 100644 --- a/packages/flutter_tools/templates/cocoapods/Podfile-swift +++ b/packages/flutter_tools/templates/cocoapods/Podfile-swift @@ -1,6 +1,9 @@ # Uncomment this line to define a global platform for your project # platform :ios, '9.0' +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + def parse_KV_file(file,seperator='=') file_abs_path = File.expand_path(file) if !File.exists? file_abs_path