after using the VSCode plugin for a while, i’ve come to find the autoresolution feature (swift.disableAutoResolve) to be more of a hindrance than a help.
the annoying behavior is when i checkout an old git commit of a project, and the VSCode plugin tries to “helpfully” update the Package.resolved, which then dirties the git state and prevents me from hopping to a different branch or commit. if i do git checkout Package.resolved, the plugin races me to try and update Package.resolved again, and so on, ad infinitum.
this doesn’t feel like a great newcomer experience, and to figure out how to disable it, you have to search through the Swift Slack and find this thread, which will disappear in a few weeks.
i personally feel that the automatic package resolution does not add enough value to be enabled by default, so it would be better to change it to be disabled by default. WDYT?
I agree this can be pretty annoying when switching branches, but it's a trade off with having up to date code completion of dependencies. This is especially important after a fresh checkout; users may not know they need to do a build or manually run a swift package resolve to start seeing full code completion. I could see this being a frequent source of confusion for new users.
I do think the extension could certainly be more nuanced here though. Perhaps there could be an option to the disableAutoResolve setting that prevents Package.resolved from being modified after package resolution?
The Package.resolved should either be versioned at a correct state and then it should not change for a fresh checkout after resolving the dependencies (without updating the dependencies!), or it should be ignored. If after resolving the dependencies you get a change in your repo state, the project is not setup as it should.
so i retraced my steps to try and figure out why this was happening in the first place, and i realized the Package.swift manifest adds a dependency that is conditionally present depending on an environment variable, as this package can be built in two “configurations”.
when i build the project in the “full” configuration, which has the environment variable set, it emits a Package.resolved that contains the extra dependency, and this is what gets checked into version control. but when the VSCode plugin runs swift package resolve on its own prerogative, it only builds the “partial” project, which omits the dependency. this is the cause of the perpetual Package.resolved conflicts.