-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Docs: Add manual plugin linking instructions for SPM #12979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
edd6ff3
efc914f
62320be
d31c8ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -59,12 +59,16 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable. | |||||
| // If the plugin name contains "_", replace with "-" for the library name. | ||||||
| .library(name: "plugin-name", targets: ["plugin_name"]) | ||||||
| ], | ||||||
| dependencies: [], | ||||||
| dependencies: [ | ||||||
| .package(name: "FlutterFramework", path: "../FlutterFramework") | ||||||
| ], | ||||||
| targets: [ | ||||||
| .target( | ||||||
| // TODO: Update your target name. | ||||||
| name: "plugin_name", | ||||||
| dependencies: [], | ||||||
| dependencies: [ | ||||||
| .product(name: "FlutterFramework", package: "FlutterFramework") | ||||||
| ], | ||||||
| resources: [ | ||||||
| // TODO: If your plugin requires a privacy manifest | ||||||
| // (e.g. if it uses any required reason APIs), update the PrivacyInfo.xcprivacy file | ||||||
|
|
@@ -166,6 +170,31 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable. | |||||
|
|
||||||
| 1. Move all files from `ios/Classes` to `ios/plugin_name/Sources/plugin_name`. | ||||||
|
|
||||||
| 1. **New in Flutter 3.41!** Add the FlutterFramework as a dependency and update Dart/Flutter version. | ||||||
|
|
||||||
| Update `Package.swift` to include `FlutterFramework`: | ||||||
|
|
||||||
| ```swift title="Package.swift" | ||||||
| dependencies: [ | ||||||
| .package(name: "FlutterFramework", path: "../FlutterFramework") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think this will make it appear highlighted |
||||||
| ], | ||||||
| targets: [ | ||||||
| .target( | ||||||
| // TODO: Update your target name. | ||||||
| name: "plugin_name", | ||||||
| dependencies: [ | ||||||
| .product(name: "FlutterFramework", package: "FlutterFramework") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think this will make it appear highlighted |
||||||
| ], | ||||||
| ``` | ||||||
|
|
||||||
| In `pubspec.yaml`, update versions to: | ||||||
|
|
||||||
| ```yaml title="pubspec.yaml" | ||||||
| environment: | ||||||
| sdk: ^3.11.0 | ||||||
| flutter: ">=3.41.0" | ||||||
| ``` | ||||||
|
|
||||||
| 1. The `ios/Assets`, `ios/Resources`, and `ios/Classes` directories should now | ||||||
| be empty and can be deleted. | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -59,6 +59,58 @@ that have migrated. | |||||
| </Tab> | ||||||
| </Tabs> | ||||||
|
|
||||||
| ## (Optional, but Recommended) Add plugin as local package in example app | ||||||
|
|
||||||
| If your plugin includes an example, it is recommended to add the plugin as a local package in the example app. This is not required, but provides better Xcode support when editing the plugin's source code in the example app. See [issue #179032](https://github.com/flutter/flutter/issues/179032). | ||||||
|
|
||||||
| ### Add plugin as local package | ||||||
|
|
||||||
| 1. In a terminal navigate to `my_plugin`. | ||||||
|
|
||||||
| 1. Run the following command to open the example app's workspace in Xcode, (replace `ios` with `macos` if your plugin targets macOS): | ||||||
|
|
||||||
| ```bash | ||||||
| open example/ios/Runner.xcworkspace | ||||||
| ``` | ||||||
|
|
||||||
| 1. Right click **Flutter** > **Add Files to “Runner”**. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 1. Select `my_plugin/ios/my_plugin` (or `macos` if your plugin targets macOS). | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| 1. Make sure “Reference files in place” is selected (it should be the default), and click **Finish**. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| This adds the plugin as a local package, but it will be referenced by absolute path, which is not desirable for distribution. To change it to a relative path, follow the steps below. | ||||||
|
|
||||||
| ### Change to relative path | ||||||
|
|
||||||
| 1. Copy “Full Path” for plugin from the File Inspector. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| 1. In terminal: | ||||||
| `open -a Xcode example/ios/Runner.xcodeproj/project.pbxproj` | ||||||
|
|
||||||
| 1. Find the following: | ||||||
| ```text | ||||||
| path = [COPIED FULL PATH]; sourceTree = "<absolute>" | ||||||
| ``` | ||||||
|
|
||||||
| For example: | ||||||
|
|
||||||
| ```text | ||||||
| path = /Users/username/path/to/my_plugin/ios/my_plugin; sourceTree = "<absolute>" | ||||||
| ``` | ||||||
|
|
||||||
| 1. And replace with relative path: | ||||||
| ```text | ||||||
| path = ../../ios/my_plugin; sourceTree = "<group>" | ||||||
| ``` | ||||||
| (Adjust `ios` to `macos` or `darwin` as needed). | ||||||
|
|
||||||
| ## How to update unit tests in a plugin's example app | ||||||
|
|
||||||
| If your plugin has native XCTests, you might need to update them to work with | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way we can remove my username from the image?