Podfile 3.8 KB

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