Skip to content

Commit dd027ae

Browse files
committed
🔧 Handle Pod plugins installation more graceful
1 parent 19e6058 commit dd027ae

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

example/ios/Podfile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,38 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
2727

2828
flutter_ios_podfile_setup
2929

30+
def install_plugin_pods(application_path = nil, relative_symlink_dir, platform)
31+
# defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
32+
application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
33+
raise 'Could not find application path' unless application_path
34+
35+
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
36+
# referring to absolute paths on developers' machines.
37+
38+
symlink_dir = File.expand_path(relative_symlink_dir, application_path)
39+
system('rm', '-rf', symlink_dir) # Avoid the complication of dependencies like FileUtils.
40+
41+
symlink_plugins_dir = File.expand_path('plugins', symlink_dir)
42+
system('mkdir', '-p', symlink_plugins_dir)
43+
44+
plugins_file = File.join(application_path, '..', '.flutter-plugins-dependencies')
45+
plugin_pods = flutter_parse_plugins_file(plugins_file, platform)
46+
plugin_pods.each do |plugin_hash|
47+
plugin_name = plugin_hash['name']
48+
plugin_path = plugin_hash['path']
49+
if (plugin_name && plugin_path)
50+
specPath = "#{plugin_path}/#{platform}/#{plugin_name}.podspec"
51+
pod plugin_name, :path => specPath
52+
end
53+
end
54+
end
55+
3056
target 'Runner' do
3157
use_frameworks!
3258
use_modular_headers!
3359

34-
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
60+
flutter_install_ios_engine_pod(File.dirname(File.realpath(__FILE__)))
61+
install_plugin_pods(File.dirname(File.realpath(__FILE__)), '.symlinks', 'ios')
3562
end
3663

3764
post_install do |installer|

0 commit comments

Comments
 (0)