Xcode reports a Swift package product as missing
Missing package product 'MyLibrary'Short answer
Xcode could not find a library product of a Swift package at build time. The usual causes are that the package was never resolved or fetched, that the product is not added to the target that imports it, or that the version requirement or repository access stops resolution. Resolve first, then check the target.
Fix it fast
1Find out which cause you have
Resolve the packages from the command line. If resolution itself fails, the message tells you why; if it succeeds, the problem is in the target setup.
xcodebuild -resolvePackageDependencies -project MyApp.xcodeproj2Match what you see, then jump to its fix
- 1
The Swift Package Dependencies section in the Project navigator is empty or shows the package without contentsThe package was not resolved or fetched yetFix - 2
The package resolves, but one target (often an extension or a test target) imports a module it was never linked toThe product is not added to the target that uses itFix - 3
The resolve command in the first step prints an error instead of finishingNo available version satisfies the requirementFix
- 1
What does the error look like?
Missing package product 'MyLibrary'
Cause 1 of 3
The package was not resolved or fetched yet
1Check
Look at the Project navigator under Swift Package Dependencies. Xcode normally resolves and fetches packages on its own, and you can trigger it yourself.
xcodebuild -resolvePackageDependencies -project MyApp.xcodeproj2Fix
Run the resolve action from the File > Packages menu in Xcode (the same step the command above performs), then build again.
# Xcode: File > Packages > Resolve Package Versions3Verify
The package expands in the Project navigator and the build no longer reports the product.
xcodebuild -scheme MyApp -destination 'generic/platform=iOS Simulator' buildConfirmed by developer.apple.com
Cause 2 of 3
The product is not added to the target that uses it
1Check
Select the target > General > Frameworks, Libraries, and Embedded Content and look for the product. Apple says you select the package's products and add them to targets.
grep -n "productRefGroup\|XCSwiftPackageProductDependency" MyApp.xcodeproj/project.pbxproj2Fix
Click + under Frameworks, Libraries, and Embedded Content of that target and add the package product.
# target > General > Frameworks, Libraries, and Embedded Content > + > pick the product3Verify
Build the target that failed.
xcodebuild -scheme MyApp -destination 'generic/platform=iOS Simulator' buildConfirmed by developer.apple.com
Cause 3 of 3
No available version satisfies the requirement
1Check
Open the project > Package Dependencies and read the requirement (version range, branch or commit). Apple says the version rule needs packages that follow semantic versioning.
xcodebuild -resolvePackageDependencies -project MyApp.xcodeproj2Fix
Change the requirement to one that a real release of the package satisfies, and confirm you can reach the repository URL.
# project > Package Dependencies > select the package > Dependency Rule3Verify
Resolution finishes without errors.
xcodebuild -resolvePackageDependencies -project MyApp.xcodeprojConfirmed by developer.apple.com
How do I stop it coming back?
- Commit the Package.resolved file so every machine resolves the same versions.
- Add a package product to every target that imports it, including extensions and test targets.
- Run the resolve command at the start of CI jobs, before the build.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
UserDefaults logs 'Failed to read values in CFPrefsPlistSource' for an app group
Settings saved by the app are not visible to its extension, widget or sibling app that share the group
This log comes from the preferences system when UserDefaults is opened for an app group's suite.
3 causes, each with a fixMobile apps
iOS app crashes: Google Maps SDK must be initialized via provideAPIKey
Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use
The Maps SDK throws this when a Maps object is created before GMSServices.provideAPIKey has run.
3 causes, each with a fixMobile apps
UIKit app crashes because it cannot find the storyboard
Could not find a storyboard named 'Main' in bundle NSBundle
UIStoryboard throws this exception when no storyboard file with that name exists in the bundle it searches.
3 causes, each with a fixMobile apps
Firebase on iOS asks for the FCM token before APNs has given one
Be sure to re-retrieve the FCM token once the APNS device token is set.
The Firebase Messaging SDK needs the APNs device token from iOS before it hands out an FCM token.
3 causes, each with a fixMobile apps
A test push from the Firebase console never shows up on the iPhone
didReceiveRegistrationToken prints a token, yet no notification arrives
When a console message is accepted but the iPhone stays silent, the break is between Firebase and APNs or inside the app.
4 causes, each with a fixMobile apps
InstanceID token() no longer works in a Swift Firebase app
Instance ID calls fail to compile after upgrading Firebase to 8.0.0 or later
Firebase removed the Instance ID dependency from Messaging in 8.0.0, so InstanceID.instanceID() calls no longer belong in a current app.
3 causes, each with a fix