Podfile-swift 2.08 KB
Newer Older
1 2 3
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

4 5 6
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

7
def parse_KV_file(file, separator='=')
8 9 10 11 12
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  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 23 24
      else
        puts "Invalid plugin specification: #{line}"
      end
25 26 27 28 29 30
  }
  return pods_ary
end

target 'Runner' do
  use_frameworks!
31 32 33

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
34 35
  system('rm -rf .symlinks')
  system('mkdir -p .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 43
  generated_xcode_build_settings.map { |p|
    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
44
      symlink = File.join('.symlinks', 'flutter')
45 46
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
47 48 49 50
    end
  }

  # Plugin Pods
51 52
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
53
    symlink = File.join('.symlinks', 'plugins', p[:name])
54 55
    File.symlink(p[:path], symlink)
    pod p[:name], :path => File.join(symlink, 'ios')
56
  }
57 58 59 60 61 62 63 64
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
65
end