Whenever Xcode updates Package.resolved, it is flipping between the lowercase name (from the Git URL) and uppercase name (from the package’s Package.swift). This has no functional impact on the project, but is messing with the file in version control. I am not sure which style is canonical, and what to actually check in. I have not determined what are the exact conditions to choose one or the other name.
Why do SwiftPM and Xcode do this, and what can I do on my end to stop this flipping between the naming styles? Which name style is the correct and canonical one?
SPM - I use whatever default ships with Xcode. I am seeing this with both Xcode 12.5 as well as Xcode 13 beta 1. I don’t think there is a way for me to specify or see the SPM version in Xcode context.
I cannot reproduce this with PLCrashReporter. Both SwiftPM (5.4) and Xcode 12.5 correctly produce the uppercase package name. Is it possible the lowercase version you have checked in is left over from some bug in older toolchains?
In general, Xcode mishandles URLs in several ways. (Unicode, percent encoding, presence of file://, presence of .git, etc.) Some cause the same sort of pin discrepancies, while others prevent resolution completely. SwiftPM is not perfect, but it is considerably more robust, reliable and deliberate about each situation. Wherever there is a difference between the two, assume Xcode is the one at fault. Aside from pestering its team through the Feedback Assistant, all you can do is pick one tool and get in the habit of always using it last before checking anything in.
Thank you. This is a very useful post. Unfortunately, it does not help when using Xcode. It would indeed fix my issue if I could specify the package names explicitly when the Git URL and package name differ, which seems to be the case for many packages. Unfortunately, there does not seem to be a way in Xcode to do that. Xcode just keeps flipping the package names in my Package.resolved between the git URL name, and name from the package’s Package.swift, using some unknown unstable heuristics.
Xcode 13 beta 1 just right now flipped again from CamelCase name PLCrashReporter to lowercase plcrashreporter. I don’t think it is related to older toolchains.
I’m considering just leaving Package.resolved out of version control. My team is small enough and build process simple enough that we don’t need to strictly version control the resolved packages.
If the difference is between the latest release and the beta, then the beta has a bug. That wouldn’t really surprise me given the identity work that has been done since the last release. I doubt the pin change should have been necessary, but if for some reason it is, then at least the version number of the pin format should have been incremented too.
If it happens from the command line (swift build), then it’s a bug in Swift. If it only happens with Xcode’s GUI (or xcodebuild), then it’s a bug in Xcode. See @wowbagger’s instructions above for reporting bugs to either.
I think this is a change in Xcode 13 beta. I’ve only seen this change happen when I use Xcode 13 - it appears to have changed from using the name of the package in the package file to the last part of the git repo. If you’re flipping back and forth between 12.5 and 13 then that’s why you keep seeing it change.
I'm constantly having this problem, too, but can't figure out exactly what triggers it. It might be when switching from Xcode 12.5.1 to 13b1 (I like to work in 13b1 because it launches our app in the simulator much faster, but I have to switch to 12.5.1 to make builds for TestFlight).
I think I'll take Package.resolved out of version control for now, too.
I didn’t file any bugs. For me and my team, the problem largely disappeared when the whole team switched to Xcode 13 betas. My Package.resolved now consistently contains the Git-URL-based package name and no longer flips.