[SwiftPM] Update .flutter-plugin-dependencies format (#158138)

In the future, it will be possible for Swift Package Manager to be enabled on one but not all platforms (see https://github.com/flutter/flutter/issues/151567#issuecomment-2455941279).

This updates the `.flutter-plugin-dependencies` file format to separate iOS's and macOS's SwiftPM enablement. For now, these platforms will always have the same value.

This `.flutter-plugin-dependencies` file is read by our CocoaPods scripts to determine whether we should use CocoaPods or not to inject plugins.

Part of https://github.com/flutter/flutter/issues/151567
This commit is contained in:
Loïc Sharma
2024-11-12 12:01:26 -08:00
committed by GitHub
parent 37d80ce25f
commit 003135e2d0
5 changed files with 63 additions and 18 deletions

View File

@@ -304,7 +304,7 @@ def flutter_install_plugin_pods(application_path = nil, relative_symlink_dir, pl
plugins_file = File.join(application_path, '..', '.flutter-plugins-dependencies')
dependencies_hash = flutter_parse_plugins_file(plugins_file)
plugin_pods = flutter_get_plugins_list(dependencies_hash, platform)
swift_package_manager_enabled = flutter_get_swift_package_manager_enabled(dependencies_hash)
swift_package_manager_enabled = flutter_get_swift_package_manager_enabled(dependencies_hash, platform)
plugin_pods.each do |plugin_hash|
plugin_name = plugin_hash['name']
@@ -353,10 +353,12 @@ def flutter_get_plugins_list(dependencies_hash, platform)
dependencies_hash['plugins'][platform] || []
end
def flutter_get_swift_package_manager_enabled(dependencies_hash)
def flutter_get_swift_package_manager_enabled(dependencies_hash, platform)
return false unless dependencies_hash.any?
return false unless dependencies_hash.has_key?('swift_package_manager_enabled')
dependencies_hash['swift_package_manager_enabled'] == true
return false unless dependencies_hash['swift_package_manager_enabled'].has_key?(platform)
dependencies_hash['swift_package_manager_enabled'][platform] == true
end
def flutter_relative_path_from_podfile(path)