main
text 77 lines 2.78 KB
Raw
1 platform :ios, '17.6'
2
3 # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4 ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5
6 project 'Runner', {
7 'Debug' => :debug,
8 'Profile' => :release,
9 'Release' => :release,
10 }
11
12 def flutter_root
13 generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
14 unless File.exist?(generated_xcode_build_settings_path)
15 raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
16 end
17
18 File.foreach(generated_xcode_build_settings_path) do |line|
19 matches = line.match(/FLUTTER_ROOT\=(.*)/)
20 return matches[1].strip if matches
21 end
22 raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
23 end
24
25 require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26
27 flutter_ios_podfile_setup
28
29 target 'Runner' do
30 use_frameworks! :linkage => :static
31
32 flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
33 target 'RunnerTests' do
34 inherit! :search_paths
35 end
36 end
37
38 post_install do |installer|
39 installer.pods_project.targets.each do |target|
40 flutter_additional_ios_build_settings(target)
41 target.build_configurations.each do |config|
42 config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '17.6'
43 end
44 end
45
46 # Add a build phase to Runner target to patch missing MinimumOSVersion in embedded frameworks
47 runner_target = installer.aggregate_targets.find { |t| t.name == 'Pods-Runner' }
48 if runner_target
49 project = runner_target.user_project
50 runner_target.user_targets.each do |target|
51 if target.name == 'Runner'
52 phase_name = 'Fix Framework MinimumOSVersion'
53 phase = target.shell_script_build_phases.find { |p| p.name == phase_name }
54 if phase.nil?
55 puts "Adding build phase: #{phase_name}"
56 phase = target.new_shell_script_build_phase(phase_name)
57 end
58 phase.shell_script = <<~SCRIPT
59 find "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" -name "Info.plist" | while read -r plist; do
60 if ! plutil -extract MinimumOSVersion xml1 -o /dev/null "$plist"; then
61 echo "Adding MinimumOSVersion to $plist"
62 plutil -insert MinimumOSVersion -string "16.4" "$plist"
63 else
64 min_os=$(plutil -extract MinimumOSVersion raw "$plist")
65 if [ -z "$min_os" ]; then
66 echo "Setting empty MinimumOSVersion to 16.4 in $plist"
67 plutil -replace MinimumOSVersion -string "16.4" "$plist"
68 fi
69 fi
70 done
71 SCRIPT
72 phase.show_env_vars_in_log = '1'
73 end
74 end
75 project.save
76 end
77 end