From 851dd5f1323b68e36f140e506eee5d5e6a9e6dba Mon Sep 17 00:00:00 2001 From: developer Date: Thu, 3 Sep 2020 14:31:46 +0800 Subject: [PATCH] fix: podfile --- ios/Podfile | 84 ++++++++++++++++++++++++++++-------------------- ios/Podfile.lock | 12 +++---- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/ios/Podfile b/ios/Podfile index f4824c8..98a90b8 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,6 +1,5 @@ # Uncomment this line to define a global platform for your project # platform :ios, '9.0' -source 'https://github.com/CocoaPods/Specs.git' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -16,49 +15,64 @@ def parse_KV_file(file, separator='=') if !File.exists? file_abs_path return []; end - pods_ary = [] + generated_key_values = {} skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) { |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - pods_ary.push({:name => podname, :path => podpath}); - else - puts "Invalid plugin specification: #{line}" - end - } - return pods_ary + File.foreach(file_abs_path) do |line| + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } + plugin = line.split(pattern=separator) + if plugin.length == 2 + podname = plugin[0].strip() + path = plugin[1].strip() + podpath = File.expand_path("#{path}", file_abs_path) + generated_key_values[podname] = podpath + else + puts "Invalid plugin specification: #{line}" + end + end + generated_key_values end target 'Runner' do + # Flutter Pod + + copied_flutter_dir = File.join(__dir__, 'Flutter') + copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') + copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') + unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) + # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. + # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. + # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. + + generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') + unless File.exist?(generated_xcode_build_settings_path) + raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) + cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; + + unless File.exist?(copied_framework_path) + FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) + end + unless File.exist?(copied_podspec_path) + FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) + end + end + + # Keep pod path relative so it can be checked into Podfile.lock. + pod 'Flutter', :path => 'Flutter' + + # Plugin Pods + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock # referring to absolute paths on developers' machines. system('rm -rf .symlinks') system('mkdir -p .symlinks/plugins') - - # Flutter Pods - generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') - if generated_xcode_build_settings.empty? - puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first." - end - generated_xcode_build_settings.map { |p| - if p[:name] == 'FLUTTER_FRAMEWORK_DIR' - symlink = File.join('.symlinks', 'flutter') - File.symlink(File.dirname(p[:path]), symlink) - pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) - end - } - - # Plugin Pods plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.map { |p| - symlink = File.join('.symlinks', 'plugins', p[:name]) - File.symlink(p[:path], symlink) - pod p[:name], :path => File.join(symlink, 'ios') - } + plugin_pods.each do |name, path| + symlink = File.join('.symlinks', 'plugins', name) + File.symlink(path, symlink) + pod name, :path => File.join(symlink, 'ios') + end end # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 9eeb5cf..c7beaa7 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,29 +1,29 @@ PODS: - - FinApplet (2.1.3) + - FinApplet (2.8.6) - Flutter (1.0.0) - mop (0.1.0): - FinApplet - Flutter DEPENDENCIES: - - Flutter (from `.symlinks/flutter/ios`) + - Flutter (from `Flutter`) - mop (from `.symlinks/plugins/mop/ios`) SPEC REPOS: - https://github.com/CocoaPods/Specs.git: + trunk: - FinApplet EXTERNAL SOURCES: Flutter: - :path: ".symlinks/flutter/ios" + :path: Flutter mop: :path: ".symlinks/plugins/mop/ios" SPEC CHECKSUMS: - FinApplet: 85f4c1b6bee9d811220fe8e6b301314ee30dd271 + FinApplet: 5eefbc232bce0b1a0532901f31578f3c48b60837 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec mop: e3eac9de90d3e331268e9c9e8308e233e540ad1c -PODFILE CHECKSUM: b66559db98de00d11e349a06f9e603856ed75d6e +PODFILE CHECKSUM: 3dbe063e9c90a5d7c9e4e76e70a821b9e2c1d271 COCOAPODS: 1.9.1