$FLUTTER_ROOT/bin/cache/artifacts/engine/ios-release
$FLUTTER_ROOT/bin/cache/artifacts/engine/ios
Flutter.xcframework | debug | release |
---|---|---|
1.17.3 | 395.9MB | 98.5MB |
1.22.4 | 426.6MB | 100.4MB |
2.0.6 | 479.8MB | 104.7MB |
2.2.2 | 1.03GB | 255.5MB |
2.5.0 | 240.9MB | 150.3MB |
2.2.2 flutter.xcframework
ios-arm64_armv7
ios-arm64_x86_64-simulator
ios-armv7_arm64
ios-x86_64-simulator
2.0.6 flutter.xcframework
ios-x86_64-simulator
ios-armv7_arm64
统计不准呢, 删除
$FLUTTER_ROOT/bin/cache
整个目录
然后重新到任意一个flutter项目,执行flutter pub get
这里当前是在一个flutter_module项目下,执行了flutter pub get
flutter_tools 会重新下载cache
$FLUTTER_ROOT/bin/cache/artifacts/engine
下面flutter
121M ./ios
91M ./ios-profile
484M ./ios-release
1, podfile
2,$FLUTTER_ROOT/packages/flutter_tools/bin/podhelper.rb
flutter_additional_ios_build_settings方法, 设置FRAMEWORK_SEARCH_PATHS
和OTHER_LDFLAGS 让没一个pod target的找到flutter.xcframework的搜索路径和导入库
return unless target.platform_name == :ios
// 跳过Flutter pod
# Return if it's not a Flutter plugin (transitive dependency).
return unless target.dependencies.any? { |dependency| dependency.name == 'Flutter' }
//FRAMEWORK_SEARCH_PATHS、OTHER_LDFLAGS
configuration_engine_dir = build_configuration.type == :debug ? debug_framework_dir : release_framework_dir
Dir.new(configuration_engine_dir).each_child do |xcframework_file|
if xcframework_file.end_with?("-simulator") # ios-x86_64-simulator
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)"
elsif xcframework_file.start_with?("ios-") # ios-armv7_arm64
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)"
else
# Info.plist or another platform.
end
end
build_configuration.build_settings['OTHER_LDFLAGS'] = '$(inherited) -framework Flutter'
3,flutter_install_ios_engine_pod方法,仍然添加一个空的Flutter pod库
def flutter_install_ios_engine_pod(ios_application_path = nil)
# defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
ios_application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
raise 'Could not find iOS application path' unless ios_application_path
copied_podspec_path = File.expand_path('Flutter.podspec', File.join(ios_application_path, 'Flutter'))
# Generate a fake podspec to represent the Flutter framework.
# This is only necessary because plugin podspecs contain `s.dependency 'Flutter'`, and if this Podfile
# does not add a `pod 'Flutter'` CocoaPods will try to download it from the CoocaPods trunk.
File.open(copied_podspec_path, 'w') { |podspec|
podspec.write <<~EOF
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
# This is a generated file; do not edit or check into version control.
#
Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => '[email protected]' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'
end
EOF
}
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
end
这么做的目的是因为 其他flutter插件会依赖这个pod
就是为了覆盖从插件里面导入了Flutter pod
所以通过以上方式,保证了所有flutter工程都指向的Flutter为同一份引用,减小磁盘空间占用。