I wonder how we (app developers) could impress upon Apple how important SPM is, so that they prioritize this higher?
In my organization we have a single app over a million lines of code, worked on by a bunch of different teams in five cities. Each team is typically responsible for at least one module within a our monorepo, however there are also some shared modules.
In a project the size of ours, Xcode project files are a major source of consternation and headaches. Up to now, each of our modules is a dynamic framework, defined by an Xcode project. However, we universally loathe Xcode projects with a heated passion because they represent everything using random GUIDs inside a nested .pbxproj file.
Xcode project files are evil because:
- they add lots of noise to code reviews
- if two developers make the same exact change independently of one another, it always causes a merge conflict because the random GUIDs will be different and/or Xcode will put things in a different random order
- git often misidentifies non-conflicting single-line changes to .pbxproj files as conflicting because it groups lines together for no reason
- when (not if) someone resolves a merge conflict incorrectly in .pbxproj files—which is easy to do—it causes project-file corruption that can break the build (or worse, not break the build, but just cause a crash)
TLDR: we want to switch to using Swift Package Manager to define all our internal modules going forwards because that way, we can never deal with Xcode project files, ever again.
Obviously the app itself will have an Xcode project file, but that's OK, since this would hardly ever get touched as everyone just works in the modules.
However, we would even love it more, if the app itself could also be a Swift Package!
Note: all of our locally-defined Swift Packages will live in the same repo, and we'll be using Carthage to build binary XCFrameworks that will be imported to the various packages.
It's not feasible for us to adapt all of our modules to packages in a single PR, so we'll have to do it one-by-one. However some of the bugs we've found when working with Swift Packages in Xcode have been preventing us from really committing to this, and it's kind of painful to think that Apple might not be prioritizing improving how SPM is integrated with Xcode.
But basically the main holdups for us are (with Apple bugreport IDs):
- Xcode Previews fail when using a dynamic Swift Package dependency that's not embedded in the framework that the preview is defined in (FB8955594)
- Removing a dynamic library Swift Package from "Embed Frameworks" in Xcode UI also removes it from "Link Frameworks and Libraries" (FB8914251)
- Remote swift package dependencies sometimes fail to resolve and take too long to resolve (FB8944736)
- @testable doesn't work in Swift packages when using an Xcode configuration with a name other than "Debug" (FB8914293)
- cannot build and run app in Release configuration with bitcode enabled if it has locally-defined Swift Package dependencies that define dynamic library targets and Deployment Post-processing is enabled (FB8956614)
- Swift Packages don't allow for custom configurations with user-defined names (not really a bug but something we're hoping to make a proposal about)
- You can't add locally-defined Swift Packages under "Swift Packages" when editing an Xcode project (kind of a counter-intuitive state of affairs)
It would also be nice to have Xcode's GUI for managing targets, inherited build configurations, and build settings get updated to work with Swift Packages instead of .xcproj files. Because as much as I love editing Package.swift files, it's not like there's an enumeration for all the possible settings keys nor are incorrect entries rejected by the compiler—leading to a situation where it's not really clear how to specify certain settings for a Swift package (like is "ENABLE_BITCODE" a SwiftSetting or a CXXSetting?). Plus, developers are accustomed to working with the existing GUI.