11# Uncomment this line to define a global platform for your project
2- platform :ios , '12.0'
3- use_frameworks!
2+ # platform :ios, '9.0'
43
54# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
65ENV [ 'COCOAPODS_DISABLE_STATS' ] = 'true'
@@ -11,79 +10,29 @@ project 'Runner', {
1110 'Release' => :release ,
1211}
1312
14- def parse_KV_file ( file , separator = '=' )
15- file_abs_path = File . expand_path ( file )
16- if ! File . exists? file_abs_path
17- return [ ] ;
13+ def flutter_root
14+ generated_xcode_build_settings_path = File . expand_path ( File . join ( '..' , 'Flutter' , 'Generated.xcconfig' ) , __FILE__ )
15+ unless File . exist? ( generated_xcode_build_settings_path )
16+ raise " #{ generated_xcode_build_settings_path } must exist. If you're running pod install manually, make sure flutter pub get is executed first"
1817 end
19- generated_key_values = { }
20- skip_line_start_symbols = [ "#" , "/" ]
21- File . foreach ( file_abs_path ) do |line |
22- next if skip_line_start_symbols . any? { |symbol | line =~ /^\s *#{ symbol } / }
23- plugin = line . split ( pattern = separator )
24- if plugin . length == 2
25- podname = plugin [ 0 ] . strip ( )
26- path = plugin [ 1 ] . strip ( )
27- podpath = File . expand_path ( "#{ path } " , file_abs_path )
28- generated_key_values [ podname ] = podpath
29- else
30- puts "Invalid plugin specification: #{ line } "
31- end
32- end
33- generated_key_values
34- end
35-
36- target 'Runner' do
37- # Flutter Pod
38-
39- copied_flutter_dir = File . join ( __dir__ , 'Flutter' )
40- copied_framework_path = File . join ( copied_flutter_dir , 'Flutter.framework' )
41- copied_podspec_path = File . join ( copied_flutter_dir , 'Flutter.podspec' )
42- unless File . exist? ( copied_framework_path ) && File . exist? ( copied_podspec_path )
43- # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
44- # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
45- # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
4618
47- generated_xcode_build_settings_path = File . join ( copied_flutter_dir , 'Generated.xcconfig' )
48- unless File . exist? ( generated_xcode_build_settings_path )
49- raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
50- end
51- generated_xcode_build_settings = parse_KV_file ( generated_xcode_build_settings_path )
52- cached_framework_dir = generated_xcode_build_settings [ 'FLUTTER_FRAMEWORK_DIR' ] ;
53-
54- unless File . exist? ( copied_framework_path )
55- FileUtils . cp_r ( File . join ( cached_framework_dir , 'Flutter.framework' ) , copied_flutter_dir )
56- end
57- unless File . exist? ( copied_podspec_path )
58- FileUtils . cp ( File . join ( cached_framework_dir , 'Flutter.podspec' ) , copied_flutter_dir )
59- end
19+ File . foreach ( generated_xcode_build_settings_path ) do |line |
20+ matches = line . match ( /FLUTTER_ROOT\= (.*)/ )
21+ return matches [ 1 ] . strip if matches
6022 end
23+ raise "FLUTTER_ROOT not found in #{ generated_xcode_build_settings_path } . Try deleting Generated.xcconfig, then run flutter pub get"
24+ end
6125
62- # Keep pod path relative so it can be checked into Podfile.lock.
63- pod 'Flutter' , :path => 'Flutter'
26+ require File . expand_path ( File . join ( 'packages' , 'flutter_tools' , 'bin' , 'podhelper' ) , flutter_root )
6427
65- # Plugin Pods
66- pod 'PSPDFKit' , podspec :'https://customers.pspdfkit.com/pspdfkit-ios/latest-framework.podspec'
28+ flutter_ios_podfile_setup
6729
68- # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
69- # referring to absolute paths on developers' machines.
70- system ( 'rm -rf .symlinks' )
71- system ( 'mkdir -p .symlinks/plugins' )
72- plugin_pods = parse_KV_file ( '../.flutter-plugins' )
73- plugin_pods . each do |name , path |
74- symlink = File . join ( '.symlinks' , 'plugins' , name )
75- File . symlink ( path , symlink )
76- pod name , :path => File . join ( symlink , 'ios' )
77- end
30+ target 'Runner' do
31+ flutter_install_all_ios_pods File . dirname ( File . realpath ( __FILE__ ) )
7832end
7933
80- # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
81- install! 'cocoapods' , :disable_input_output_paths => true
82-
8334post_install do |installer |
8435 installer . pods_project . targets . each do |target |
85- target . build_configurations . each do |config |
86- config . build_settings [ 'ENABLE_BITCODE' ] = 'NO'
87- end
36+ flutter_additional_ios_build_settings ( target )
8837 end
8938end
0 commit comments