Podfile 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. platform :osx, '10.11'
  2. # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
  3. ENV['COCOAPODS_DISABLE_STATS'] = 'true'
  4. project 'Runner', {
  5. 'Debug' => :debug,
  6. 'Profile' => :release,
  7. 'Release' => :release,
  8. }
  9. def parse_KV_file(file, separator='=')
  10. file_abs_path = File.expand_path(file)
  11. if !File.exists? file_abs_path
  12. return [];
  13. end
  14. pods_ary = []
  15. skip_line_start_symbols = ["#", "/"]
  16. File.foreach(file_abs_path) { |line|
  17. next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
  18. plugin = line.split(pattern=separator)
  19. if plugin.length == 2
  20. podname = plugin[0].strip()
  21. path = plugin[1].strip()
  22. podpath = File.expand_path("#{path}", file_abs_path)
  23. pods_ary.push({:name => podname, :path => podpath});
  24. else
  25. puts "Invalid plugin specification: #{line}"
  26. end
  27. }
  28. return pods_ary
  29. end
  30. def pubspec_supports_macos(file)
  31. file_abs_path = File.expand_path(file)
  32. if !File.exists? file_abs_path
  33. return false;
  34. end
  35. File.foreach(file_abs_path) { |line|
  36. return true if line =~ /^\s*macos:/
  37. }
  38. return false
  39. end
  40. target 'Runner' do
  41. use_frameworks!
  42. use_modular_headers!
  43. # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  44. # referring to absolute paths on developers' machines.
  45. ephemeral_dir = File.join('Flutter', 'ephemeral')
  46. symlink_dir = File.join(ephemeral_dir, '.symlinks')
  47. symlink_plugins_dir = File.join(symlink_dir, 'plugins')
  48. system("rm -rf #{symlink_dir}")
  49. system("mkdir -p #{symlink_plugins_dir}")
  50. # Flutter Pods
  51. generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig'))
  52. if generated_xcconfig.empty?
  53. puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
  54. end
  55. generated_xcconfig.map { |p|
  56. if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
  57. symlink = File.join(symlink_dir, 'flutter')
  58. File.symlink(File.dirname(p[:path]), symlink)
  59. pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path]))
  60. end
  61. }
  62. # Plugin Pods
  63. plugin_pods = parse_KV_file('../.flutter-plugins')
  64. plugin_pods.map { |p|
  65. symlink = File.join(symlink_plugins_dir, p[:name])
  66. File.symlink(p[:path], symlink)
  67. if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml'))
  68. pod p[:name], :path => File.join(symlink, 'macos')
  69. end
  70. }
  71. end
  72. # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
  73. install! 'cocoapods', :disable_input_output_paths => true