Advertisement
Guest User

flutter podfile

a guest
Oct 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.20 KB | None | 0 0
  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.   # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  31.   # referring to absolute paths on developers' machines.
  32.   use_frameworks!
  33.   system('rm -rf .symlinks')
  34.   system('mkdir -p .symlinks/plugins')
  35.  
  36.   # Flutter Pods
  37.   generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
  38.   if generated_xcode_build_settings.empty?
  39.     puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
  40.   end
  41.   generated_xcode_build_settings.map { |p|
  42.     if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
  43.       symlink = File.join('.symlinks', 'flutter')
  44.       File.symlink(File.dirname(p[:path]), symlink)
  45.       pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
  46.     end
  47.   }
  48.  
  49.   # Plugin Pods
  50.   plugin_pods = parse_KV_file('../.flutter-plugins')
  51.   plugin_pods.map { |p|
  52.     symlink = File.join('.symlinks', 'plugins', p[:name])
  53.     File.symlink(p[:path], symlink)
  54.     pod p[:name], :path => File.join(symlink, 'ios')
  55.   }
  56. end
  57.  
  58. post_install do |installer|
  59.   installer.pods_project.targets.each do |target|
  60.     target.build_configurations.each do |config|
  61.       config.build_settings['ENABLE_BITCODE'] = 'NO'
  62.       config.build_settings['SWIFT_VERSION'] = '4.0'
  63.     end
  64.   end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement