Repository navigation
Conversation
In a SwiftPM app, `spm update` and the "Sync SPM Autolinking" build phase run codegen, which overwrote build/generated/ios/Package.swift with the CocoaPods template. The SwiftPM scripts wrote the SwiftPM version back seconds later. If an open Xcode resolved packages in between, it cached a broken build plan, and every later build failed with "Missing package product" until the PIFCache in derived data was deleted. Codegen now keeps an existing Package.swift that is the SwiftPM version.
2 of 3 tasks
This branch has not been deployed
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:
In a SwiftPM app, a build in the Xcode window can fail with
Missing package product '<library>'after a native library is removed or added, and the error stays after more builds and after an Xcode restart. Only deleting Xcode'sPIFCachefolder in derived data fixes it.The cause:
spm update, and the "Sync SPM Autolinking" build phase, run codegen.build/generated/ios/Package.swiftfrom the CocoaPods template. In a SwiftPM app that version points to a package path that does not exist.Package.swiftwith the old targets. Later builds reuse that plan.This change: codegen keeps an existing
Package.swiftthat is the SwiftPM version, detected by a line ofPackage.swift.spm-template. CocoaPods apps are unchanged.Limits:
build/is deleted, no file exists yet, so codegen still writes the CocoaPods version once before the SwiftPM scripts replace it. Xcode has no cached plan for the project at that point.spm deinit, an existing SwiftPMPackage.swiftnow stays inbuild/generated/ios. CocoaPods builds do not use it.Changelog:
[IOS] [FIXED] - SwiftPM: codegen no longer briefly replaces the SwiftPM
Package.swift, which could make Xcode fail with "Missing package product" until its cache was deletedTest Plan:
Unit tests:
29 suites, 1322 tests passed. The new
generatePackageSwift-test.jshas 3 tests; without the fix, "keeps the SwiftPM Package.swift installed by the SwiftPM scripts" fails.eslintandflow focus-checkon both files: no errors.App (RN 0.89.0-rc.4, SwiftPM app, Xcode 27.2, fixed file copied into
node_modules; an npmdependenciesscript runsnpx react-native spm updateso the update happens while the project is open in Xcode):build/generated/ios/Package.swiftevery 50 ms duringspm update,npm uninstallandnpm install: without the fix it was the CocoaPods version for about 6 s; with the fix it never was.npm uninstall @react-native-picker/picker, start a build at the moment the AutolinkedPackage.swiftdrops the library, then build twice more.Missing package product 'rncpicker_RNCPicker.RNCPicker'