From 47278a3c4e1e3f8773d66baa8896d2ddf6101339 Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" Date: Tue, 5 May 2026 21:45:36 -0700 Subject: [PATCH 1/4] Adding instructions on using Swift Package Manager --- .../developing-packages.md | 86 ++++++++++--------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/sites/docs/src/content/packages-and-plugins/developing-packages.md b/sites/docs/src/content/packages-and-plugins/developing-packages.md index 94a2c5f8c1f..f92bcce0116 100644 --- a/sites/docs/src/content/packages-and-plugins/developing-packages.md +++ b/sites/docs/src/content/packages-and-plugins/developing-packages.md @@ -297,7 +297,7 @@ dependencies: hello_windows: ^1.0.0 ``` -Note that as shown here, an app-facing package can have +Note that, as shown here, an app-facing package can have some platforms implemented within the package, and others in endorsed federated implementations. @@ -463,51 +463,60 @@ the path will end with `hello/darwin/Classes` instead.) You can run the example app by pressing the run (▶) button. -##### Add CocoaPod dependencies +##### Add native Darwin dependencies (Swift Package Manager) -:::warning -Flutter is migrating to [Swift Package Manager][] -to manage iOS and macOS native dependencies. -Flutter's support of Swift Package Manager is under development. -The implementation might change in the future. -Swift Package Manager support is only available -on Flutter's [`main` channel][]. -Flutter continues to support CocoaPods. -::: +Flutter uses Swift Package Manager as the primary strategy to manage native iOS +and macOS dependencies. -[Swift Package Manager]: https://www.swift.org/documentation/package-manager/ -[`main` channel]: /install/upgrade#switching-flutter-channels +To add a dependency to your plugin using Swift Package Manager: -Use the following instructions to add `HelloPod` with the version `0.0.1`: +1. Create a `Package.swift` file in your plugin's `ios/` or `macos/` directory + inside a subdirectory matching your plugin name. +2. Declare your native dependency within the `dependencies` array of the + `Package.swift` descriptor file: -1. Specify the dependency at the end of `ios/hello.podspec`: +```swift title="Package.swift" +dependencies: [ + .package(url: "https://github.com/path/to/HelloLibrary.git", from: "1.0.0") +] +``` - ```ruby - s.dependency 'HelloPod', '0.0.1' - ``` +For complete details and instructions on structuring native folders, resource +bundling, or handling hybrid setups, see the [Swift Package Manager for plugin +authors](/packages-and-plugins/swift-package-manager/for-plugin-authors) guide. - For private pods, refer to - [Private CocoaPods][] to ensure repo access: +##### Add CocoaPod dependencies (Legacy) - ```ruby - s.source = { - # For pods hosted on GitHub - :git => "https://github.com/path/to/HelloPod.git", - # Alternatively, for pods hosted locally - # :path => "file:///path/to/private/repo", - :tag => s.version.to_s - }` - ``` +Flutter continues to support CocoaPods for backward compatibility. If your +plugin needs to support developers who haven't migrated to Swift Package +Manager yet, specify your CocoaPods dependency at the end of +`ios/hello.podspec`: -[Private CocoaPods]: https://guides.cocoapods.org/making/private-cocoapods.html +```ruby +s.dependency 'HelloPod', '0.0.1' +``` + +For private pods, refer to +[Private CocoaPods][] to ensure repo access: -2. Installing the plugin +```ruby +s.source = { + # For pods hosted on GitHub + :git => "https://github.com/path/to/HelloPod.git", + # Alternatively, for pods hosted locally + # :path => "file:///path/to/private/repo", + :tag => s.version.to_s + }` +``` + +[Private CocoaPods]: https://guides.cocoapods.org/making/private-cocoapods.html - - Add the plugin in the project’s `pubspec.yaml` dependencies. - - Run `flutter pub get`. - - In the project’s `ios/` directory, run `pod install`. +##### Installing the plugin dependencies -The pod should appear in the installation summary. +To fetch and link the plugin's dependencies, add the plugin to your app project's +`pubspec.yaml` dependencies, and run `flutter pub get`. Flutter automatically +resolves and wires up the Swift Package Manager descriptors or CocoaPods +pod files during the native app build step. If your plugin requires a privacy manifest, for example, if it uses any **required reason APIs**, @@ -1005,13 +1014,6 @@ For additional details on `.podspec` files, see the All web dependencies are handled by the `pubspec.yaml` file, like any other Dart package. -{% comment %} - -### MacOS - -PENDING -{% endcomment %} - [bind-native]: /platform-integration/bind-native-code [CocoaPods Documentation]: https://guides.cocoapods.org/syntax/podspec.html [Dart library package]: {{site.dart-site}}/guides/libraries/create-library-packages From 43495a28ba6d5ff583bffb9a94f9e14f08ee1291 Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" Date: Tue, 5 May 2026 21:50:35 -0700 Subject: [PATCH 2/4] Remove errant backtick --- .../src/content/packages-and-plugins/developing-packages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sites/docs/src/content/packages-and-plugins/developing-packages.md b/sites/docs/src/content/packages-and-plugins/developing-packages.md index f92bcce0116..f38ca75af47 100644 --- a/sites/docs/src/content/packages-and-plugins/developing-packages.md +++ b/sites/docs/src/content/packages-and-plugins/developing-packages.md @@ -506,7 +506,7 @@ s.source = { # Alternatively, for pods hosted locally # :path => "file:///path/to/private/repo", :tag => s.version.to_s - }` + } ``` [Private CocoaPods]: https://guides.cocoapods.org/making/private-cocoapods.html From 0b929235da48bebda23bcbb1e9406ec24fdac0f0 Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" Date: Thu, 7 May 2026 13:51:43 -0700 Subject: [PATCH 3/4] tweak --- .../developing-packages.md | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sites/docs/src/content/packages-and-plugins/developing-packages.md b/sites/docs/src/content/packages-and-plugins/developing-packages.md index f38ca75af47..2c63c93104f 100644 --- a/sites/docs/src/content/packages-and-plugins/developing-packages.md +++ b/sites/docs/src/content/packages-and-plugins/developing-packages.md @@ -419,8 +419,11 @@ We recommend you edit the Android code using Android Studio. Before editing the Android platform code in Android Studio, first make sure that the code has been built at least once (in other words, run the example app from your IDE/editor, -or in a terminal execute -`cd hello/example; flutter build apk --config-only`). +or in a terminal execute: + +```console +cd hello/example; flutter build apk --config-only +``` Then use the following steps: @@ -465,13 +468,12 @@ You can run the example app by pressing the run (▶) button. ##### Add native Darwin dependencies (Swift Package Manager) -Flutter uses Swift Package Manager as the primary strategy to manage native iOS -and macOS dependencies. +Flutter uses Swift Package Manager as the primary strategy to manage +native iOS and macOS dependencies. To add a dependency to your plugin using Swift Package Manager: -1. Create a `Package.swift` file in your plugin's `ios/` or `macos/` directory - inside a subdirectory matching your plugin name. +1. Create a `Package.swift` file in your plugin's `ios/` or `macos/` directory. 2. Declare your native dependency within the `dependencies` array of the `Package.swift` descriptor file: @@ -482,8 +484,10 @@ dependencies: [ ``` For complete details and instructions on structuring native folders, resource -bundling, or handling hybrid setups, see the [Swift Package Manager for plugin -authors](/packages-and-plugins/swift-package-manager/for-plugin-authors) guide. +bundling, or handling hybrid setups, +visit the [Swift Package Manager for plugin authors][] guide. + +[Swift Package Manager for plugin authors]: /packages-and-plugins/swift-package-manager/for-plugin-authors ##### Add CocoaPod dependencies (Legacy) From 5275cfbfd66c01c2abaf80655c2816880873599e Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" Date: Tue, 12 May 2026 11:29:07 -0700 Subject: [PATCH 4/4] Incorporate feedback --- .../src/content/packages-and-plugins/developing-packages.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sites/docs/src/content/packages-and-plugins/developing-packages.md b/sites/docs/src/content/packages-and-plugins/developing-packages.md index 2c63c93104f..f81df7872a5 100644 --- a/sites/docs/src/content/packages-and-plugins/developing-packages.md +++ b/sites/docs/src/content/packages-and-plugins/developing-packages.md @@ -473,7 +473,8 @@ native iOS and macOS dependencies. To add a dependency to your plugin using Swift Package Manager: -1. Create a `Package.swift` file in your plugin's `ios/` or `macos/` directory. +1. Create a `Package.swift` file in your plugin's `ios/my_plugin_name` + or `macos/my_plugin_name` directory. 2. Declare your native dependency within the `dependencies` array of the `Package.swift` descriptor file: