Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Comment on lines +473 to +474
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The instruction to place the Package.swift file inside a subdirectory matching the plugin name is incorrect. For Flutter's Swift Package Manager integration, the Package.swift file should be located directly in the ios/ or macos/ directory of the plugin.

Suggested change
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnpryan, is this true?

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'
```

2. Installing the plugin
For private pods, refer to
[Private CocoaPods][] to ensure repo access:

- Add the plugin in the project’s `pubspec.yaml` dependencies.
- Run `flutter pub get`.
- In the project’s `ios/` directory, run `pod install`.
```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

The pod should appear in the installation summary.
##### Installing the plugin dependencies

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**,
Expand Down Expand Up @@ -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 %}
<!-- Remove until we have better text. -->
### 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
Expand Down
Loading