Skip to content

Commit cf7336d

Browse files
committed
Update iOS config.
1 parent 8a88a6d commit cf7336d

File tree

1 file changed

+14
-65
lines changed

1 file changed

+14
-65
lines changed

example/ios/Podfile

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,80 +10,29 @@ project 'Runner', {
1010
'Release' => :release,
1111
}
1212

13-
def parse_KV_file(file, separator='=')
14-
file_abs_path = File.expand_path(file)
15-
if !File.exists? file_abs_path
16-
return [];
13+
def flutter_root
14+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15+
unless File.exist?(generated_xcode_build_settings_path)
16+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
1717
end
18-
generated_key_values = {}
19-
skip_line_start_symbols = ["#", "/"]
20-
File.foreach(file_abs_path) do |line|
21-
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22-
plugin = line.split(pattern=separator)
23-
if plugin.length == 2
24-
podname = plugin[0].strip()
25-
path = plugin[1].strip()
26-
podpath = File.expand_path("#{path}", file_abs_path)
27-
generated_key_values[podname] = podpath
28-
else
29-
puts "Invalid plugin specification: #{line}"
30-
end
31-
end
32-
generated_key_values
33-
end
34-
35-
target 'Runner' do
36-
# Flutter Pod
37-
38-
copied_flutter_dir = File.join(__dir__, 'Flutter')
39-
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
40-
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
41-
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
42-
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
43-
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
44-
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
4518

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-
53-
unless File.exist?(copied_framework_path)
54-
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
55-
end
56-
unless File.exist?(copied_podspec_path)
57-
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
58-
end
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
5922
end
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24+
end
6025

61-
# Keep pod path relative so it can be checked into Podfile.lock.
62-
pod 'Flutter', :path => 'Flutter'
26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
6327

64-
# Plugin Pods
28+
flutter_ios_podfile_setup
6529

66-
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
67-
# referring to absolute paths on developers' machines.
68-
system('rm -rf .symlinks')
69-
system('mkdir -p .symlinks/plugins')
70-
plugin_pods = parse_KV_file('../.flutter-plugins')
71-
plugin_pods.each do |name, path|
72-
# symlink = File.join('.symlinks', 'plugins', name)
73-
# File.symlink(path, symlink)
74-
# pod name, :path => File.join(symlink, 'ios')
75-
specPath = "#{path}/ios/#{name}.podspec"
76-
pod name,:path=>specPath
77-
end
30+
target 'Runner' do
31+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
7832
end
7933

80-
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
81-
install! 'cocoapods', :disable_input_output_paths => true
82-
8334
post_install do |installer|
8435
installer.pods_project.targets.each do |target|
85-
target.build_configurations.each do |config|
86-
config.build_settings['ENABLE_BITCODE'] = 'NO'
87-
end
36+
flutter_additional_ios_build_settings(target)
8837
end
8938
end

0 commit comments

Comments
 (0)