Design
When building for SwiftPM add2app, the plugins that support SwiftPM should be copied from pubcache to the --output directory, under a Plugins subdirectory.
├── FlutterPluginRegistrant
├── Plugins
│ ├── plugin_a
│ ├── plugin_b
...
If a plugin does not have a dependency on the FlutterFramework, it should add it. For example, if the plugin's Package.swift looks like this:
let package = Package(
name: "plugin_a",
products: [
.library(name: "plugin-a", targets: ["plugin_a"]),
],
dependencies: [],
targets: [
.target(
name: "plugin_a",
dependencies: [
.target(name: "plugin_a_helper"),
]
),
.target(
name: "plugin_a_helper",
dependencies: []
),
]
)
You can run the following commands to update the Package.swift
swift package add-dependency ../FlutterFramework --type path
swift package add-target-dependency FlutterFramework plugin_a --package FlutterFramework
swift package add-target-dependency FlutterFramework plugin_a_helper --package FlutterFramework
The resulting Package.swift would looked like:
let package = Package(
name: "plugin_a",
products: [
.library(name: "plugin-a", targets: ["plugin_a"]),
],
dependencies: [
.package(name: "FlutterFramework", path: "../FlutterFramework")
],
targets: [
.target(
name: "plugin_a",
dependencies: [
.target(name: "plugin_a_helper"),
.product(name: "FlutterFramework", package: "FlutterFramework")
]
),
.target(
name: "plugin_a_helper",
dependencies: [
.product(name: "FlutterFramework", package: "FlutterFramework")
]
),
]
)
Design
When building for SwiftPM add2app, the plugins that support SwiftPM should be copied from pubcache to the
--outputdirectory, under aPluginssubdirectory.If a plugin does not have a dependency on the FlutterFramework, it should add it. For example, if the plugin's Package.swift looks like this:
You can run the following commands to update the Package.swift
swift package add-dependency ../FlutterFramework --type pathswift package add-target-dependency FlutterFramework plugin_a --package FlutterFrameworkswift package add-target-dependency FlutterFramework plugin_a_helper --package FlutterFrameworkThe resulting Package.swift would looked like: