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
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.1, or changing to exact version number which is different from current package version.
8. If these steps above doesn’t work, try removing packages and re-adding again on the step 7 screen. This is powerful! This should fix all problems. But it changes
project.pbxproj file. The good news is, after you get a stable build state on Xcode, you can discard the
project.pbxproj changes. You do not need to commit the file to Git or other VCSs.