Repository navigation
Conversation
The scaffolder wrote publicHeadersPath: before resources: in the target. Swift requires the declared parameter order, so a library with podspec resources and public headers failed to resolve. Bump SCAFFOLDER_VERSION to 21 so existing scaffolds regenerate.
cipolleschi
approved these changes
Oct 26, 2026
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D127581976. |
Collaborator
|
This pull request was successfully merged by @chrfalch in d576b40 When will my fix make it into a release? | How to file a pick request? |
|
@cipolleschi merged this pull request in d576b40. |
usama-liaqat
pushed a commit
to usama-liaqat/react-native
that referenced
this pull request
Nov 14, 2026
Summary: The SwiftPM scaffolder (`npx react-native spm scaffold`) writes a `Package.swift` for a library from its podspec. When the podspec has `s.resources` and the library has public headers, the scaffolder writes `publicHeadersPath:` before `resources:` in the target. Swift requires the parameters in their declared order, so package resolution fails: ``` error: argument 'resources' must precede argument 'publicHeadersPath' ``` This change: 1. Writes `resources:` before `publicHeadersPath:` in the scaffolded target (`scaffold-package-swift.js`). 2. Raises `SCAFFOLDER_VERSION` from 20 to 21. `spm scaffold` then writes the manifest again for libraries that still have a manifest from an older scaffolder version. `spm update` does not do this. The autolinker (`generate-spm-autolinking.js`) writes the same two arguments in the same wrong order, at two places. Neither place can fail today, so this PR leaves them unchanged: - `generateAutolinkedPackageSwift` writes inline targets, but `main()` passes none. - `generateSynthPackageSwift` runs, but only for `spmModules` targets, and those never set `resources`. So it never writes the `resources:` line today. A note on privacy manifests: this work started from the belief that scaffolded libraries lose the `PrivacyInfo.xcprivacy` file that their podspec lists in `resource_bundles`. That is not the case. The scaffolded target uses `path: "."`, so SwiftPM finds the file by itself and copies it into the app. react#57305 is a different fix: it covers React Native's own privacy manifests in the prebuilt `React.framework`. This PR does not depend on other open PRs. ## Changelog: [IOS] [FIXED] - SwiftPM: scaffolded `Package.swift` writes `resources:` before `publicHeadersPath:`, so libraries with podspec resources and public headers resolve Pull Request resolved: react#59494 Test Plan: Unit tests (from the repository root): ``` yarn jest packages/react-native/scripts/spm ``` - A new test checks that `resources:` comes before `publicHeadersPath:`. It failed before the fix (`Expected: < 1471, Received: 1509`) and passes after it. - All 25 test suites and 1188 tests pass. - `eslint --max-warnings 0` and `prettier --check` are clean on both changed files. End to end, with a new React Native 0.88.0 app and `react-native-device-info` 15.0.2, converted with `npx react-native spm add --deintegrate`: 1. For this test only, I added `s.resources = ['ios/PrivacyInfo.xcprivacy']` to the library's podspec. Without the fix, `spm scaffold` wrote a manifest that failed with the error above. 2. With this fix applied to the app's `node_modules/react-native/scripts/spm/scaffold-package-swift.js`: - `npx react-native spm scaffold` wrote version 21, with `resources:` before `publicHeadersPath:`. - An `xcodebuild` Debug build for the iOS simulator gave `BUILD SUCCEEDED`. - The app contains `RNDeviceInfo_RNDeviceInfo.bundle/PrivacyInfo.xcprivacy`, and it is byte-identical to the library's file. The build gave no duplicate-resource warning. Not covered: the device-info build also needed a hand edit to `publicHeadersPath: "ios/RNDeviceInfo"`. The scaffolder writes `"ios"`, and Xcode 27.1 RC rejects that header layout. That is a separate scaffolder issue, and a separate PR will fix it. Reviewed By: christophpurrer Differential Revision: D127581976 Pulled By: cipolleschi fbshipit-source-id: c6a958d6cabcc73ef98b5f1bce9d65b15052159a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
The SwiftPM scaffolder (
npx react-native spm scaffold) writes aPackage.swiftfor a library from its podspec. When the podspec hass.resourcesand the library has public headers, the scaffolder writespublicHeadersPath:beforeresources:in the target. Swift requires the parameters in their declared order, so package resolution fails:This change:
resources:beforepublicHeadersPath:in the scaffolded target (scaffold-package-swift.js).SCAFFOLDER_VERSIONfrom 20 to 21.spm scaffoldthen writes the manifest again for libraries that still have a manifest from an older scaffolder version.spm updatedoes not do this.The autolinker (
generate-spm-autolinking.js) writes the same two arguments in the same wrong order, at two places. Neither place can fail today, so this PR leaves them unchanged:generateAutolinkedPackageSwiftwrites inline targets, butmain()passes none.generateSynthPackageSwiftruns, but only forspmModulestargets, and those never setresources. So it never writes theresources:line today.A note on privacy manifests: this work started from the belief that scaffolded libraries lose the
PrivacyInfo.xcprivacyfile that their podspec lists inresource_bundles. That is not the case. The scaffolded target usespath: ".", so SwiftPM finds the file by itself and copies it into the app. #57305 is a different fix: it covers React Native's own privacy manifests in the prebuiltReact.framework.This PR does not depend on other open PRs.
Changelog:
[IOS] [FIXED] - SwiftPM: scaffolded
Package.swiftwritesresources:beforepublicHeadersPath:, so libraries with podspec resources and public headers resolveTest Plan:
Unit tests (from the repository root):
resources:comes beforepublicHeadersPath:. It failed before the fix (Expected: < 1471, Received: 1509) and passes after it.eslint --max-warnings 0andprettier --checkare clean on both changed files.End to end, with a new React Native 0.88.0 app and
react-native-device-info15.0.2, converted withnpx react-native spm add --deintegrate:s.resources = ['ios/PrivacyInfo.xcprivacy']to the library's podspec. Without the fix,spm scaffoldwrote a manifest that failed with the error above.node_modules/react-native/scripts/spm/scaffold-package-swift.js:npx react-native spm scaffoldwrote version 21, withresources:beforepublicHeadersPath:.xcodebuildDebug build for the iOS simulator gaveBUILD SUCCEEDED.RNDeviceInfo_RNDeviceInfo.bundle/PrivacyInfo.xcprivacy, and it is byte-identical to the library's file. The build gave no duplicate-resource warning.Not covered: the device-info build also needed a hand edit to
publicHeadersPath: "ios/RNDeviceInfo". The scaffolder writes"ios", and Xcode 27.1 RC rejects that header layout. That is a separate scaffolder issue, and a separate PR will fix it.