Sometimes after executing git checkout branch
or git reset another-branch
(while Xcode is open) I find out that the Package.resolved
file gets mysteriously deleted. I can easily restore it from git or just recreate it from Xcode, but it gets annoying. It seems like Xcode itself deletes it. Any idea why it happens and how to fix it?
Question posted in Xcode
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
2
Answers
It appears that this is related to different versions of Swift Package Manager/XCode. Using XCode 15.3 checking out code from a different XCode version, I see that
Package.resolved
has been deleted, but if I go toFile -> Packages -> Resolve Package Versions
, I get a modifiedPackage.resolved
with the diff below, and most importantly I’m able to build successfully:Don’t switch branches or reset or anything like that with Xcode open. Just don’t do it. You can make Xcode very unhappy and Weird Stuff (tm, pat. pend.) can result. Xcode’s Git integration is extremely poor, and changing stuff on disk (like wit git switch, checkout, or reset) while Xcode has things open just confuses the heck out of Xcode. This is true even if you ordered those changes by way of the Xcode interface!
Instead, simply close the project window, switch branches using the command line, and then open the project window. Then wait while Xcode indexes afresh, and so forth. Yes, this can take a long time. Go get a cup of coffee or something.
One of the things Xcode will do during this preparation after you open the project window is to reconstruct the Packages.resolved file. So this should solve the issue.