I have a build error saying that all my SPM packages are missing. I decided to remove and re-add each package to the project, but each attempt at adding a package gives me the following error:
Package.resolved file is corrupted or malformed; fix or delete the file to continue
I’ve tried deleting the Package.resolved
file and letting it regenerate (it didn’t), but I get the same error message. Any ideas on how to fix this?
12
Answers
I found this answer on forums.swift.org and it worked for me:
Also this issue may be caused by the fact that project opened from .xcworkspace instead of .xcodeproj file.
We transitioned to SPM from CocoaPods and old .xcworkspace messed things up.
Just did have the same problem after merging updates. And for me helped to deleting
Package.resolved
file.I tried the solution suggested by Maxwell above but it didn’t resolve the problem for me.
The error appeared with Xcode 12 but upgrading to Xcode 13 didn’t fix it either.
Instead, I decided to take Xcode at its word and delete the Package.resolved file. But where is it? I did this:
In Finder, tap Shift+Cmd+. to reveal hidden files and folders.
The Package.resolved file is inside your .xcodeproj directory at [appName].xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Right click on .xcodeproj and project.xcworkspace to show package contents.
Move the Package.resolved file to the bin, and then empty the bin.
Reopen Xcode and open your project again. This gave me another error:
the package at ‘/’ cannot be accessed (Couldn’t read ‘4.5.0’:
In Xcode, File / Packages / Reset package caches.
The Swift Package Manager starts working on this.
Rebuild the project. The error had gone and my project rebuilt successfully.
I join the above and would like to supplement (or rather simplify) this procedure a little, you can not close xcode and do the same, while the Package.resolved file will automatically be added to the swiftpm folder, then you just update the pods.
When using CocoaPods and SwiftPackageManager in a project together there are two Package.resolved files. One is in YourProj.xcworkspace and the other is in YourProj.xcproj -> project.xcworkspace. I had to delete both and then it worked again.
Just to add another valid scenario, I got the same error on the CI with a little bit more detail:
It meant the Xcode version of the CI didn’t support that schema format.
Updating the Xcode version to match our development environment fixed the issue.
Make sure the dependency graph is in good shape. Xcode is terribly bad at identifying and reporting problems with version conflicts.
reason of the issue is that Package.resolved file is corrupted.you need delete the disable package and Package.resolved.
you could not find the Package.resolved in Finder,you should select it in the project.the detail as follow:
The accepted answer works but finding it was baffling.
For people who looked at the accepted answer but can’t where it’s at, look at the comment underneath by @Andres Canella: project.xcworkspace/xcshareddata/swiftpm/Package.resolved
1- Close Xcode
2- Open your project folder then right click on the white project icon and select Show Package Contents
3- Open the xcshareddata folder, then open the swiftpm folder, then open the configuration folder, you should then see the Package.resolved file, just delete it.
None of these worked for me because there was a specific package that was corrupted and needed to be removed.
I removed it by opening Xcode and tapping on the project. Selecting the main project file and tapping the Package Dependencies tab. Here I was able to select the corrupted package and remove it from the project.
Then I proceed to delete the DerivedData folder from my project folder and then I followed the steps mention by Andrew
My internet connection got lost in the middle of downloading the dependencies and when I started xcode back up the file was corrupted in the workspace and there was no corresponding swiftPM folder in the xcode project package. Deleting the workspace spm allowed me to realize that one specific package wasn’t being fetched and errored out the rest of the dependencies. I later found out that the library required a min version of xcode and i had to update in order for the package to download. The workspace I was building was made from another developer and I pulled it down from a repo.