Podfile 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # Uncomment this line to define a global platform for your project
  2. platform :ios, '9.3'
  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. # Flutter Pod
  33. copied_flutter_dir = File.join(__dir__, 'Flutter')
  34. copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  35. copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  36. unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
  37. # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
  38. # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
  39. # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
  40. generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
  41. unless File.exist?(generated_xcode_build_settings_path)
  42. raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  43. end
  44. generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
  45. cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
  46. unless File.exist?(copied_framework_path)
  47. FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
  48. end
  49. unless File.exist?(copied_podspec_path)
  50. FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
  51. end
  52. end
  53. # Keep pod path relative so it can be checked into Podfile.lock.
  54. pod 'Flutter', :path => 'Flutter'
  55. # Plugin Pods
  56. # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  57. # referring to absolute paths on developers' machines.
  58. system('rm -rf .symlinks')
  59. system('mkdir -p .symlinks/plugins')
  60. plugin_pods = parse_KV_file('../.flutter-plugins')
  61. plugin_pods.each do |name, path|
  62. symlink = File.join('.symlinks', 'plugins', name)
  63. File.symlink(path, symlink)
  64. if name == 'flutter_ffmpeg'
  65. pod name+'/full', :path => File.join(symlink, 'ios')
  66. else
  67. pod name, :path => File.join(symlink, 'ios')
  68. end
  69. end
  70. end
  71. # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
  72. install! 'cocoapods', :disable_input_output_paths => true
  73. post_install do |installer|
  74. installer.pods_project.targets.each do |target|
  75. target.build_configurations.each do |config|
  76. config.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = ''
  77. config.build_settings['ENABLE_BITCODE'] = 'NO'
  78. end
  79. end
  80. end