Sometimes I encounter ununderstandable Xcode build errors. It says “Failed to parse the manifest file”, “Missing package product ‘Xxxxxxxx’, Package resolution errors must be fixed before building”. I got this error, maybe once in a month in average. This error is hard to fix and time consuming.

How to fix “Failed to parse the manifest file” errors (definitive)

Remove all packages and re-adding again. This should fix all the package problems! But it changes project.pbxproj file. The good news is, after you get a stable build on Xcode, you can discard the project.pbxproj changes. You do not need to commit the file to Git or other VCSs.

How to fix “Failed to parse the manifest file” errors (obsoleted)

Aug. 13, 2022 updated: This section is obsoleted.

1. Close the project.

2. Quit Xcode.

3. Remove the contents of DerivedData folders and the Cache folder.

$ rm -rf ~/Library/Developer/Xcode/DerivedData/
$ rm -rf ~/Library/Caches/org.swift.swiftpm/

4. Run xcodebuild on the project folder.

$ xcodebuild -resolvePackageDependencies -project YourProject.xcodeproj -scheme YourScheme -platform="iOS, name:'Any iOS Device'"

- You must change "YourProject" and "YourScheme" for your environment.
- "Any iOS Device" can be your real device names and your simulator names.

ex.
$ xcodebuild -resolvePackageDependencies -project Product1.xcodeproj -scheme Staging -platform="iOS, name:'iPhone X (14.5)'"

5. Open Xcode.

6. Open the project.

7. Last magic. Change package version rule. Small change would be fine. For example, changing minimum version requirement from 5.4.0 to 5.4.1, or changing to exact version number which is different from current package version.

References

  • https://stackoverflow.com/questions/70581075/xcode-13-2-1-unable-to-resolve-swift-package-manager