|
| 1 | +# Uncomment this line to define a global platform for your project |
| 2 | +# platform :ios, '9.0' |
| 3 | + |
| 4 | +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. |
| 5 | +ENV['COCOAPODS_DISABLE_STATS'] = 'true' |
| 6 | + |
| 7 | +def parse_KV_file(file, separator='=') |
| 8 | + file_abs_path = File.expand_path(file) |
| 9 | + if !File.exists? file_abs_path |
| 10 | + return []; |
| 11 | + end |
| 12 | + pods_ary = [] |
| 13 | + skip_line_start_symbols = ["#", "/"] |
| 14 | + File.foreach(file_abs_path) { |line| |
| 15 | + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } |
| 16 | + plugin = line.split(pattern=separator) |
| 17 | + if plugin.length == 2 |
| 18 | + podname = plugin[0].strip() |
| 19 | + path = plugin[1].strip() |
| 20 | + podpath = File.expand_path("#{path}", file_abs_path) |
| 21 | + pods_ary.push({:name => podname, :path => podpath}); |
| 22 | + else |
| 23 | + puts "Invalid plugin specification: #{line}" |
| 24 | + end |
| 25 | + } |
| 26 | + return pods_ary |
| 27 | +end |
| 28 | + |
| 29 | +target 'Runner' do |
| 30 | + use_frameworks! |
| 31 | + |
| 32 | + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock |
| 33 | + # referring to absolute paths on developers' machines. |
| 34 | + system('rm -rf Pods/.symlinks') |
| 35 | + system('mkdir -p Pods/.symlinks/plugins') |
| 36 | + |
| 37 | + # Flutter Pods |
| 38 | + generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') |
| 39 | + if generated_xcode_build_settings.empty? |
| 40 | + puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." |
| 41 | + end |
| 42 | + generated_xcode_build_settings.map { |p| |
| 43 | + if p[:name] == 'FLUTTER_FRAMEWORK_DIR' |
| 44 | + symlink = File.join('Pods', '.symlinks', 'flutter') |
| 45 | + File.symlink(File.dirname(p[:path]), symlink) |
| 46 | + pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) |
| 47 | + end |
| 48 | + } |
| 49 | + |
| 50 | + # Plugin Pods |
| 51 | + plugin_pods = parse_KV_file('../.flutter-plugins') |
| 52 | + plugin_pods.map { |p| |
| 53 | + symlink = File.join('Pods', '.symlinks', 'plugins', p[:name]) |
| 54 | + File.symlink(p[:path], symlink) |
| 55 | + pod p[:name], :path => File.join(symlink, 'ios') |
| 56 | + } |
| 57 | +end |
| 58 | + |
| 59 | +pre_install do |installer| |
| 60 | + # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289 |
| 61 | + Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} |
| 62 | +end |
| 63 | + |
| 64 | +post_install do |installer| |
| 65 | + installer.pods_project.targets.each do |target| |
| 66 | + target.build_configurations.each do |config| |
| 67 | + config.build_settings['ENABLE_BITCODE'] = 'NO' |
| 68 | + end |
| 69 | + # workaround for https://github.com/CocoaPods/CocoaPods/issues/7463 |
| 70 | + target.headers_build_phase.files.each do |file| |
| 71 | + file.settings = { 'ATTRIBUTES' => ['Public'] } |
| 72 | + end |
| 73 | + end |
| 74 | +end |
0 commit comments