Skip to content

[iOS][swiftpm] Documentation updates - #58084

Open
chrfalch wants to merge 6 commits into
spm/spm-modules-guardfrom
spm/library-author-docs
Open

[iOS][swiftpm] Documentation updates#58084
chrfalch wants to merge 6 commits into
spm/spm-modules-guardfrom
spm/library-author-docs

Conversation

@chrfalch

@chrfalch chrfalch commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary:

There were some missing explanation regarding naming of SwiftPM modules which led to some issues for library authors, and based on changes in the functionality the docs also needed a few minor updates to support these changes (we're still in preview, so changes are expected).

This was seen in the PR here powersync-ja/powersync-js#1076.

This PR updates the docs.

Changelog:

[IOS] [FIXED] - Updated SwiftPM documentation

Test Plan:

✅ Verify that the docs are aligned with the implementation

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 24, 2026
@github-actions

Copy link
Copy Markdown

Caution

Invalid Base Branch

The base branch for this PR is spm/spm-modules-guard, which is not main or a -stable branch.
Are you sure you want to target this branch?

@chrfalch
chrfalch requested a review from cipolleschi August 25, 2026 09:57
The derivation rule, the `spm.name` override and the names React Native
reserves were only discoverable from the autolinker's source or from the error a
collision produces. Write them down where a library author looks: the scoped
package case that surprises people (`@scope/react-native` derives `ReactNative`,
and gets its scope back as `ScopeReactNative`), the two reasons to set
`spm.name` and its charset, the reserved names in one table, what happens when
two libraries derive the same name — who moves, who stays, and when the build
fails anyway — and the npm `files` requirement that makes the override reach
consumers at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chrfalch
chrfalch force-pushed the spm/spm-modules-guard branch from cdaf50b to dfdb704 Compare August 25, 2026 09:59
@chrfalch
chrfalch force-pushed the spm/library-author-docs branch from a859dcc to 0d7aeb7 Compare August 25, 2026 09:59

@cipolleschi cipolleschi left a comment

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.

thanks for putting these docs together. I left a few suggestions and questions.

Comment thread packages/react-native/scripts/spm/__docs__/spm-scripts.md Outdated
Comment thread packages/react-native/scripts/spm/__docs__/spm-scripts.md Outdated
Comment thread packages/react-native/scripts/spm/__docs__/spm-scripts.md Outdated
Comment on lines +387 to +391
- **One target.** `spm add` attaches the `Autolinked` aggregate to a single app
target (`--productName` picks it when the project has several), and modules
reach only that target. Known gap: rn-tester's test targets
(`RNTesterUnitTests`, `RNTesterIntegrationTests`) get their own pods under
CocoaPods, and `spm.modules` has no equivalent for them yet.

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.

this is not super clear. it means that an app can only have 1 SPM module? or that all the SPM modules declared by the app are conflated in a single target?

Comment on lines +454 to +458
| `@scope/common` | `Common` |
| `@scope/react-native` | `ReactNative` |

The last row is the surprise: dropping the scope makes `@scope/react-native`
derive `ReactNative`, a [reserved name](#names-react-native-reserves). A scoped

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.

can we change the logic so we always keep the scope? It feels easier to implement and to remember, no?

It also helps with clashes.
For example, both Expo and Firebase might be publishing a @expo/common and @firebase/common package.
IF we keep the scoping, we have ExpoCommon and FirebaseCommon, while if we drop it, we have
two Common packages, with a clash.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This was done to try to always match the existing header files folder name - which seemed to fit better without the scope - meaning less changes for our devs. I also agree that we could just use the scoped name all over - but that might lead to a few more changes by library authors.

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.

uhm... in that case, it's probably better to fail immediately and asks the user to add a spm.name.
I don't think we have any one that has #include<Common/SomeHeader.h>. This should also simplify the implementation.

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.

or in general why are we trying to do something smart? I can see more cases where this heuristic will fail than cases where it will work.
For example:

  • every react-native-xxxx probably does not have #import<ReactNativeXXX/Header>.
  • every scoped package is unlikely that they will always use the second part of the scope.

Perhaps we should not try to be smart and we should just ask library maintainers to specify that the spm.name has to be their import prefix.

WDYT?

@chrfalch chrfalch Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Great points. What about reading from podspec if it exists and use the header_dir field? Then react-native-svg would default to RNSVG - which is correct? This will be a new change in a separate PR (since the naming stuff is not really changed in this iteration - we just documented and added collision handling (#58044).

Comment thread packages/react-native/scripts/spm/__docs__/spm-scripts.md
chrfalch and others added 5 commits August 25, 2026 15:59
Co-authored-by: Riccardo Cipolleschi <cipolleschi@meta.com>
Co-authored-by: Riccardo Cipolleschi <cipolleschi@meta.com>
Co-authored-by: Riccardo Cipolleschi <cipolleschi@meta.com>
The limit read as a cap on how many modules an app may declare, or as all of
them being merged into one target. It is neither: each entry is its own
SwiftPM target, and the constraint is which targets can use them — only the
app target `spm add` attached the aggregate to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The GitHub suggestion commits reflowed prose past the print width, padded a
table cell, and left trailing whitespace on a heading — prettier --list-different
flags the file, which is what the lint job runs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants