Skip to content

Commit bd9b801

Browse files
sfshaza2parlough
andauthored
Updating the SPM guide for iOS and macOS (#13459)
Fixes #13447 --------- Co-authored-by: Parker Lougheed <parlough@gmail.com>
1 parent 0b4607a commit bd9b801

20 files changed

Lines changed: 242 additions & 360 deletions

sites/docs/src/_includes/docs/swift-package-manager/how-to-enable-disable.md

Lines changed: 0 additions & 85 deletions
This file was deleted.

sites/docs/src/_includes/docs/swift-package-manager/migrate-ios-project-manually.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
1-
Once you [turn on Swift Package Manager][], the Flutter CLI tries to migrate
2-
your project to use Swift Package Manager the next time you run your app
3-
using the CLI.
1+
Migrating to SwiftPM requires updating the
2+
`ios/Runner.xcodeproj/project.pbxproj` and
3+
`ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme` files.
44

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

8-
If the automatic migration fails, use the steps below to add Swift Package
9-
Manager integration to a project manually.
10-
11-
Before migrating manually, [file an issue][]; this helps the Flutter team
12-
improve the automatic migration process.
13-
Include the error message and, if possible, include a copy of
14-
the following files in your issue:
15-
16-
* `ios/Runner.xcodeproj/project.pbxproj`
17-
* `ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme`
18-
(or the xcsheme for the flavor used)
19-
20-
### Step 1: Add FlutterGeneratedPluginSwiftPackage Package Dependency {:.no_toc}
21-
22-
1. Open your app (`ios/Runner.xcworkspace`) in Xcode.
7+
1. In Xcode, open `ios/Runner.xcworkspace`.
238
1. Navigate to **Package Dependencies** for the project.
249

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

3823
<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**" />
3924

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

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

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

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

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

sites/docs/src/_includes/docs/swift-package-manager/migrate-ios-project.md

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
1-
Once you [turn on Swift Package Manager][], the Flutter CLI tries to migrate
2-
your project to use Swift Package Manager the next time you run your app
3-
using the CLI.
1+
Migrating to SwiftPM requires updating the
2+
`macos/Runner.xcodeproj/project.pbxproj` and
3+
`macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme` files.
44

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

8-
If the automatic migration fails, use the steps below to add Swift Package
9-
Manager integration to a project manually.
10-
11-
Before migrating manually, [file an issue][]; this helps the Flutter team
12-
improve the automatic migration process.
13-
Include the error message and, if possible, include a copy of
14-
the following files in your issue:
15-
16-
* `macos/Runner.xcodeproj/project.pbxproj`
17-
* `macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme`
18-
(or the xcscheme for the flavor used)
19-
20-
### Step 1: Add FlutterGeneratedPluginSwiftPackage Package Dependency {:.no_toc}
21-
22-
1. Open your app (`macos/Runner.xcworkspace`) in Xcode.
7+
1. In Xcode, open `macos/Runner.xcworkspace`.
238
1. Navigate to **Package Dependencies** for the project.
249

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

3823
<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**" />
3924

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

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

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

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

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

7055
<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" />
7156

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

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

sites/docs/src/_includes/docs/swift-package-manager/migrate-macos-project.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

sites/docs/src/_includes/docs/swift-package-manager/migrate-objective-c-plugin.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Replace `plugin_name` throughout this guide with the name of your plugin.
2-
The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
2+
The example below uses `ios`, replace `ios` with `macos` or `darwin`, as applicable.
33

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

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

@@ -104,7 +105,7 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
104105
],
105106
```
106107

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

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

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

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

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

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

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

295-
1. Open the `ios/plugin_name/` directory in Xcode.
298+
1. In Xcode, open the `ios/plugin_name/` directory.
296299

297300
1. In Xcode, open your `Package.swift` file.
298-
Verify Xcode doesn't produce any warnings or errors for this file.
301+
Verify that Xcode doesn't produce any warnings or errors for this file.
299302

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

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

326329
:::tip
@@ -360,8 +363,8 @@ The example below uses `ios`, replace `ios` with `macos`/`darwin` as applicable.
360363
:::
361364

362365
1. If your `ios/plugin_name/Sources/plugin_name/include` directory only
363-
contains a `.gitkeep`, you'll want update your `.gitignore` to include the
364-
following:
366+
contains a `.gitkeep`, you'll want to update your `.gitignore` to
367+
include the following:
365368

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

445-
1. Open the plugin's example app in Xcode.
448+
1. In Xcode, open the plugin's example app.
446449
Ensure that **Package Dependencies** shows in the left
447450
**Project Navigator**.
448451

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

454457
* Follow instructions for [testing plugins][].
455458

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

0 commit comments

Comments
 (0)