1- # 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.
2- # source 'https://cdn.cocoapods.org/'
3-
41# Uncomment this line to define a global platform for your project
52# platform :ios, '9.0'
63
@@ -18,51 +15,67 @@ def parse_KV_file(file, separator='=')
1815 if !File . exists? file_abs_path
1916 return [ ] ;
2017 end
21- pods_ary = [ ]
18+ generated_key_values = { }
2219 skip_line_start_symbols = [ "#" , "/" ]
23- File . foreach ( file_abs_path ) { |line |
24- next if skip_line_start_symbols . any? { |symbol | line =~ /^\s *#{ symbol } / }
25- plugin = line . split ( pattern = separator )
26- if plugin . length == 2
27- podname = plugin [ 0 ] . strip ( )
28- path = plugin [ 1 ] . strip ( )
29- podpath = File . expand_path ( "#{ path } " , file_abs_path )
30- pods_ary . push ( { :name => podname , :path => podpath } ) ;
31- else
32- puts "Invalid plugin specification: #{ line } "
33- end
34- }
35- return pods_ary
20+ File . foreach ( file_abs_path ) do |line |
21+ next if skip_line_start_symbols . any? { |symbol | line =~ /^\s *#{ symbol } / }
22+ plugin = line . split ( pattern = separator )
23+ if plugin . length == 2
24+ podname = plugin [ 0 ] . strip ( )
25+ path = plugin [ 1 ] . strip ( )
26+ podpath = File . expand_path ( "#{ path } " , file_abs_path )
27+ generated_key_values [ podname ] = podpath
28+ else
29+ puts "Invalid plugin specification: #{ line } "
30+ end
31+ end
32+ generated_key_values
3633end
3734
3835target 'Runner' do
3936 use_frameworks!
37+ use_modular_headers!
38+
39+ # Flutter Pod
4040
41- # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
42- # referring to absolute paths on developers' machines.
43- system ( 'rm -rf .symlinks' )
44- system ( 'mkdir -p .symlinks/plugins' )
41+ copied_flutter_dir = File . join ( __dir__ , 'Flutter' )
42+ copied_framework_path = File . join ( copied_flutter_dir , 'Flutter.framework' )
43+ copied_podspec_path = File . join ( copied_flutter_dir , 'Flutter.podspec' )
44+ unless File . exist? ( copied_framework_path ) && File . exist? ( copied_podspec_path )
45+ # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
46+ # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
47+ # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
4548
46- # Flutter Pods
47- generated_xcode_build_settings = parse_KV_file ( './Flutter/Generated.xcconfig' )
48- if generated_xcode_build_settings . empty?
49- puts "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 . map { |p |
52- if p [ :name ] == 'FLUTTER_FRAMEWORK_DIR'
53- symlink = File . join ( '.symlinks' , 'flutter' )
54- File . symlink ( File . dirname ( p [ :path ] ) , symlink )
55- pod 'Flutter' , :path => File . join ( symlink , File . basename ( p [ :path ] ) )
49+ generated_xcode_build_settings_path = File . join ( copied_flutter_dir , 'Generated.xcconfig' )
50+ unless File . exist? ( generated_xcode_build_settings_path )
51+ raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
5652 end
57- }
53+ generated_xcode_build_settings = parse_KV_file ( generated_xcode_build_settings_path )
54+ cached_framework_dir = generated_xcode_build_settings [ 'FLUTTER_FRAMEWORK_DIR' ] ;
55+
56+ unless File . exist? ( copied_framework_path )
57+ FileUtils . cp_r ( File . join ( cached_framework_dir , 'Flutter.framework' ) , copied_flutter_dir )
58+ end
59+ unless File . exist? ( copied_podspec_path )
60+ FileUtils . cp ( File . join ( cached_framework_dir , 'Flutter.podspec' ) , copied_flutter_dir )
61+ end
62+ end
63+
64+ # Keep pod path relative so it can be checked into Podfile.lock.
65+ pod 'Flutter' , :path => 'Flutter'
5866
5967 # Plugin Pods
68+
69+ # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
70+ # referring to absolute paths on developers' machines.
71+ system ( 'rm -rf .symlinks' )
72+ system ( 'mkdir -p .symlinks/plugins' )
6073 plugin_pods = parse_KV_file ( '../.flutter-plugins' )
61- plugin_pods . map { | p |
62- symlink = File . join ( '.symlinks' , 'plugins' , p [ : name] )
63- File . symlink ( p [ : path] , symlink )
64- pod p [ : name] , :path => File . join ( symlink , 'ios' )
65- }
74+ plugin_pods . each do | name , path |
75+ symlink = File . join ( '.symlinks' , 'plugins' , name )
76+ File . symlink ( path , symlink )
77+ pod name , :path => File . join ( symlink , 'ios' )
78+ end
6679end
6780
6881# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
0 commit comments