Podfile-ios-swift 2.34 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 8 9 10 11 12
project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

13
def parse_KV_file(file, separator='=')
14 15 16 17 18
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  pods_ary = []
19
  skip_line_start_symbols = ["#", "/"]
20
  File.foreach(file_abs_path) { |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
        pods_ary.push({:name => podname, :path => podpath});
28 29 30
      else
        puts "Invalid plugin specification: #{line}"
      end
31 32 33 34 35 36
  }
  return pods_ary
end

target 'Runner' do
  use_frameworks!
37 38 39

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
40 41
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')
42

43
  # Flutter Pods
44
  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
45
  if generated_xcode_build_settings.empty?
46
    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first."
47
  end
48 49
  generated_xcode_build_settings.map { |p|
    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
50
      symlink = File.join('.symlinks', 'flutter')
51 52
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
53 54 55 56
    end
  }

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

65 66 67
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

68 69 70 71 72 73
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
74
end