Xcode automatically updating Package.resolved

Has anybody found a way to stop Xcode from automatically updating MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved whenever the project is opened?

When building from a command line, there is a flag that can be passed, -disableAutomaticPackageResolution, but there doesn't seem to be a way to achieve the same behaviour when just opening a project file with Xcode.

I'm surprised that the default behaviour is to automatically update dependencies - no other dependency manager that I know of does that.

EDIT: This doesn't seem to happen always, seems to be specific to a branch.

I doesn’t update them unless the current pins are somehow invalid (which makes it look to Xcode as though you just edited the manifest since last time).

I suspect there is something unique about the particular branch that confuses Xcode into thinking the pins are stale. If you manually look at the .resolved file’s JSON, does it look correct and complete? For example, one thing that has caused that for me—at least in earlier toolchains—is when a package graph has the same package referred to both with and without .git at the end of the URL.

I'm poking around trying to find an answer to this problem still, as our Package.resolved file looks good (per @SDGGiesbrecht 's recommendation on what to check into). I've also ensured that Package.resolved is getting checked in properly. I'm at a loss on how to prevent this, and I'm not sure how the problem isn't more prevalent! I'm wondering if there's just something configured wrong on our end.

As @Srdan_Rasic mentions, it seems like this happens when Xcode attempts to update dependencies when we switch branches, which could be useful if the .resolved file were different; however, Xcode is clearly disregarding the current status of the .resolved file and attempting to do an update regardless of any changes, which is definitely not useful.

Currently, our options seem to be:

  1. Pin our dependency versions explicitly. This should fix things (unless there's another strange Xcode issue with SPM), but is terribly inconvenient for obvious reasons.
  2. Reset/revert the file changes when we don't want them, which is basically every time we switch branches. This is how we do it today. We switch branches, wait for Xcode to resolve packages, and check git status to see if it updated stuff.

Anyone have any thoughts? Thanks in advance!

I do not know. Figuring it out would probably require seeing the actual project in question. If your project is open source, you could post a link. Otherwise you may have to try getting confidential help through Apple’s developer program.

Terms of Service

Privacy Policy

Cookie Policy