Skip to content
Open
Show file tree
Hide file tree
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
Once you [turn on Swift Package Manager][], the Flutter CLI tries to migrate
your project to use Swift Package Manager the next time you run your app
using the CLI.
Migrating to SwiftPM requires updating the
`ios/Runner.xcodeproj/project.pbxproj` and
`ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme` files.

However, the Flutter CLI tool might be unable to migrate your project
automatically if there are unexpected modifications.
### Step 1: Add FlutterGeneratedPluginSwiftPackage package dependency {:.no_toc}

If the automatic migration fails, use the steps below to add Swift Package
Manager integration to a project manually.

Before migrating manually, [file an issue][]; this helps the Flutter team
improve the automatic migration process.
Include the error message and, if possible, include a copy of
the following files in your issue:

* `ios/Runner.xcodeproj/project.pbxproj`
* `ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme`
(or the xcsheme for the flavor used)

### Step 1: Add FlutterGeneratedPluginSwiftPackage Package Dependency {:.no_toc}

1. Open your app (`ios/Runner.xcworkspace`) in Xcode.
1. In Xcode, open `ios/Runner.xcworkspace`.
1. Navigate to **Package Dependencies** for the project.

<DashImage image="development/packages-and-plugins/swift-package-manager/package-dependencies.png" caption="The project's package dependencies" />
Expand All @@ -37,12 +22,12 @@ the following files in your issue:

<DashImage image="development/packages-and-plugins/swift-package-manager/add-generated-framework.png" caption="Ensure that `FlutterGeneratedPluginSwiftPackage` was added to **Frameworks, Libraries, and Embedded Content**" />

### Step 2: Add Run Prepare Flutter Framework Script Pre-Action {:.no_toc}
### Step 2: Add Run Prepare Flutter Framework Script Pre-action {:.no_toc}

**The following steps must be completed for each flavor.**

1. Go to **Product > Scheme > Edit Scheme**.
1. Expand the **Build** section in the left side bar.
1. Expand the **Build** section in the left sidebar.
1. Click **Pre-actions**.
1. Click the <Icon id="add" label="add/plus"></Icon> button and
select **New Run Script Action** from the menu.
Expand All @@ -63,7 +48,7 @@ the following files in your issue:

### Step 3: Run app {:.no_toc}

1. Run the app in Xcode.
1. In Xcode, run the app.
1. Ensure that **Run Prepare Flutter Framework Script** runs as a pre-action
and that `FlutterGeneratedPluginSwiftPackage` is a target dependency.

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
Once you [turn on Swift Package Manager][], the Flutter CLI tries to migrate
your project to use Swift Package Manager the next time you run your app
using the CLI.
Migrating to SwiftPM requires updating the
`macos/Runner.xcodeproj/project.pbxproj` and
`macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme` files.

However, the Flutter CLI tool might be unable to migrate your project
automatically if there are unexpected modifications.
### Step 1: Add FlutterGeneratedPluginSwiftPackage package dependency {:.no_toc}

If the automatic migration fails, use the steps below to add Swift Package
Manager integration to a project manually.

Before migrating manually, [file an issue][]; this helps the Flutter team
improve the automatic migration process.
Include the error message and, if possible, include a copy of
the following files in your issue:

* `macos/Runner.xcodeproj/project.pbxproj`
* `macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme`
(or the xcscheme for the flavor used)

### Step 1: Add FlutterGeneratedPluginSwiftPackage Package Dependency {:.no_toc}

1. Open your app (`macos/Runner.xcworkspace`) in Xcode.
1. In Xcode, open `macos/Runner.xcworkspace`.
1. Navigate to **Package Dependencies** for the project.

<DashImage image="development/packages-and-plugins/swift-package-manager/package-dependencies.png" caption="The project's package dependencies" />
Expand All @@ -37,12 +22,12 @@ the following files in your issue:

<DashImage image="development/packages-and-plugins/swift-package-manager/add-generated-framework.png" caption="Ensure that `FlutterGeneratedPluginSwiftPackage` was added to **Frameworks, Libraries, and Embedded Content**" />

### Step 2: Add Run Prepare Flutter Framework Script Pre-Action {:.no_toc}
### Step 2: Add Run Prepare Flutter Framework Script Pre-action {:.no_toc}

**The following steps must be completed for each flavor.**

1. Go to **Product > Scheme > Edit Scheme**.
1. Expand the **Build** section in the left side bar.
1. Expand the **Build** section in the left sidebar.
1. Click **Pre-actions**.
1. Click the <Icon id="add" label="add/plus"></Icon> button
and select **New Run Script Action** from the menu.
Expand All @@ -63,13 +48,12 @@ the following files in your issue:

### Step 3: Run app {:.no_toc}

1. Run the app in Xcode.
1. In Xcode, run the app.
1. Ensure that **Run Prepare Flutter Framework Script** runs as a pre-action
and that `FlutterGeneratedPluginSwiftPackage` is a target dependency.

<DashImage image="development/packages-and-plugins/swift-package-manager/flutter-pre-action-build-log.png" caption="Ensure `Run Prepare Flutter Framework Script` runs as a pre-action" />

1. Ensure that the app runs on the command line with `flutter run`.

[turn on Swift Package Manager]: /packages-and-plugins/swift-package-manager/for-app-developers/#how-to-turn-on-swift-package-manager
[file an issue]: {{site.github}}/flutter/flutter/issues/new?template=2_bug.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Replace `plugin_name` throughout this guide with the name of your plugin.
The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
The example below uses `ios`, replace `ios` with `macos` or `darwin`, as applicable.

1. [Turn on the Swift Package Manager feature][enableSPM].
1. Ensure that you are running Flutter 3.44 or later. This enables SwiftPM by default.

1. Start by creating a directory under the `ios`, `macos`, and/or `darwin`
directories.
Expand Down Expand Up @@ -73,9 +73,10 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
dependencies: [],
resources: [
// TODO: If your plugin requires a privacy manifest
// (e.g. if it uses any required reason APIs), update the PrivacyInfo.xcprivacy file
// (in other words, if it uses any required reason APIs),
// update the PrivacyInfo.xcprivacy file
// to describe your plugin's privacy impact, and then uncomment this line.
// For more information, see:
// For more information, visit:
// https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
// .process("PrivacyInfo.xcprivacy"),

Expand Down Expand Up @@ -104,7 +105,7 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
],
```

[supported platforms]: https://developer.apple.com/documentation/packagedescription/supportedplatform
[supported platforms]: {{site.apple-dev}}/documentation/packagedescription/supportedplatform

1. Update the package, library, and target names in your `Package.swift` file.

Expand All @@ -129,9 +130,10 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
dependencies: [],
resources: [
// TODO: If your plugin requires a privacy manifest
// (e.g. if it uses any required reason APIs), update the PrivacyInfo.xcprivacy file
// (for example, if it uses any required reason APIs),
// update the PrivacyInfo.xcprivacy file
// to describe your plugin's privacy impact, and then uncomment this line.
// For more information, see:
// For more information, visit:
// https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
// .process("PrivacyInfo.xcprivacy"),

Expand Down Expand Up @@ -160,9 +162,10 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
```swift title="Package.swift"
resources: [
// TODO: If your plugin requires a privacy manifest
// (e.g. if it uses any required reason APIs), update the PrivacyInfo.xcprivacy file
// (for example, if it uses any required reason APIs),
// update the PrivacyInfo.xcprivacy file
// to describe your plugin's privacy impact, and then uncomment this line.
// For more information, see:
// For more information, visit:
// https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
[!.process("PrivacyInfo.xcprivacy"),!]

Expand All @@ -175,8 +178,8 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
1. Move any resource files from `ios/Assets` to
`ios/plugin_name/Sources/plugin_name` (or a subdirectory).
Add the resource files to your `Package.swift` file, if applicable.
For more instructions, see
[https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package](https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package).
For more instructions, visit
[https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package]({{site.apple-dev}}/documentation/xcode/bundling-resources-with-a-swift-package).

1. Move any public headers from `ios/Classes` to
`ios/plugin_name/Sources/plugin_name/include/plugin_name`.
Expand Down Expand Up @@ -292,10 +295,10 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.

1. Update your `Package.swift` file with any customizations you might need.

1. Open the `ios/plugin_name/` directory in Xcode.
1. In Xcode, open the `ios/plugin_name/` directory.

1. In Xcode, open your `Package.swift` file.
Verify Xcode doesn't produce any warnings or errors for this file.
Verify that Xcode doesn't produce any warnings or errors for this file.

:::tip
If Xcode doesn't show any files, quit Xcode (**Xcode > Quit Xcode**) and
Expand All @@ -320,7 +323,7 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
```

1. Make any other customizations. For more information on how to write a
`Package.swift` file, see
`Package.swift` file, visit
[https://developer.apple.com/documentation/packagedescription](https://developer.apple.com/documentation/packagedescription).

:::tip
Expand Down Expand Up @@ -360,8 +363,8 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
:::

1. If your `ios/plugin_name/Sources/plugin_name/include` directory only
contains a `.gitkeep`, you'll want update your `.gitignore` to include the
following:
contains a `.gitkeep`, you'll want to update your `.gitignore` to
include the following:

```text title=".gitignore"
!.gitkeep
Expand Down Expand Up @@ -442,7 +445,7 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
[undo the Swift Package Manager migration][removeSPM].
:::

1. Open the plugin's example app in Xcode.
1. In Xcode, open the plugin's example app.
Ensure that **Package Dependencies** shows in the left
**Project Navigator**.

Expand All @@ -453,7 +456,6 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.

* Follow instructions for [testing plugins][].

[enableSPM]: /packages-and-plugins/swift-package-manager/for-plugin-authors#how-to-turn-on-swift-package-manager
[`PrivacyInfo.xcprivacy` file]: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
[`public_header_files`]: https://guides.cocoapods.org/syntax/podspec.html#public_header_files
[Swift Package Manager's documentation]: {{site.github}}/apple/swift-package-manager/blob/main/Documentation/Usage.md#creating-c-language-targets
Expand Down
Loading
Loading