Podfile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Uncomment this line to define a global platform for your project
  2. platform :ios, '9.0'
  3. # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
  4. ENV['COCOAPODS_DISABLE_STATS'] = 'true'
  5. project 'Runner', {
  6. 'Debug' => :debug,
  7. 'Profile' => :release,
  8. 'Release' => :release,
  9. }
  10. def parse_KV_file(file, separator='=')
  11. file_abs_path = File.expand_path(file)
  12. if !File.exists? file_abs_path
  13. return [];
  14. end
  15. generated_key_values = {}
  16. skip_line_start_symbols = ["#", "/"]
  17. File.foreach(file_abs_path) do |line|
  18. next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
  19. plugin = line.split(pattern=separator)
  20. if plugin.length == 2
  21. podname = plugin[0].strip()
  22. path = plugin[1].strip()
  23. podpath = File.expand_path("#{path}", file_abs_path)
  24. generated_key_values[podname] = podpath
  25. else
  26. puts "Invalid plugin specification: #{line}"
  27. end
  28. end
  29. generated_key_values
  30. end
  31. target 'Runner' do
  32. use_frameworks!
  33. use_modular_headers!
  34. # Flutter Pod
  35. copied_flutter_dir = File.join(__dir__, 'Flutter')
  36. copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  37. copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  38. unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
  39. # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
  40. # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
  41. # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
  42. generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
  43. unless File.exist?(generated_xcode_build_settings_path)
  44. raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  45. end
  46. generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
  47. cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
  48. unless File.exist?(copied_framework_path)
  49. FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
  50. end
  51. unless File.exist?(copied_podspec_path)
  52. FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
  53. end
  54. end
  55. # Keep pod path relative so it can be checked into Podfile.lock.
  56. pod 'Flutter', :path => 'Flutter'
  57. # Plugin Pods
  58. # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  59. # referring to absolute paths on developers' machines.
  60. system('rm -rf .symlinks')
  61. system('mkdir -p .symlinks/plugins')
  62. plugin_pods = parse_KV_file('../.flutter-plugins')
  63. plugin_pods.each do |name, path|
  64. symlink = File.join('.symlinks', 'plugins', name)
  65. File.symlink(path, symlink)
  66. pod name, :path => File.join(symlink, 'ios')
  67. end
  68. end
  69. # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
  70. install! 'cocoapods', :disable_input_output_paths => true
  71. post_install do |installer|
  72. installer.pods_project.targets.each do |target|
  73. target.build_configurations.each do |config|
  74. config.build_settings['ENABLE_BITCODE'] = 'NO'
  75. end
  76. end
  77. end