SPM has a lot of issues, though. For example: if you depend on a static library, it will both statically link it _and_ embed the binary; likewise, a static library dependency in a framework will cause build failures ~70% of the time when clean. There's others around resources, etc.
I do not believe SPM is mature enough to be the entire platform, and worst yet if you experience any problems it is entirely impossible to customize the behavior. I think it's going to be another year or 2 before dropping CocoaPods entirely is a fair choice for libraries -- SPM works for the most basic use cases, but not all.
Ah. I see why this has not been an issue with me for most (maybe not all) of my projects. Most have only a single-layer dependency.
Looks like this happens for chained dependencies ("a Swift package with binary dependencies", below), in apps with extensions (I have none).
This is from the 12.4 notes[0]:
> If you use a Swift package with binary dependencies in an app with extensions, the build system incorrectly embeds the binary dependencies alongside the extension in the PlugIns directory, causing validation of the archived app to fail. (69834549) (FB8761306)
Workaround: Add a scheme post-build action which removes the embedded binaries from the PlugIns directory after the build, e.g. rm -rf "${TARGET_BUILD_DIR}/${TARGET_NAME}.app"/PlugIns/.framework.*
I do not see a note in the 12.5 notes addressing this[1].
Any particular reason for the insult? I don't remember saying anything bad about you.
Maybe, we could have found more in common than you may think. We both seem to be passionate about the same kind of stuff.
I was under the impression that we should make an effort to be a wee bit more respectful with each other, than we might in venues like Reddit or SO (where they have the "digital sneer" down to a science).
That was the only thing I could find that mentioned anything like it at all.
I checked my builds every which way from Sunday, and I never had a double-embedded static lib. I was wondering if they may have been mixed up.
Otherwise, there's nothing at all about it.
I pretty much always use static libs, but sometimes, I may need a .framework. I've been using SPM for months, and have published a bunch of libs. I do tend to be conservative, and reduce the surface of dependencies wherever possible. I eat my own dog food, and am the only consumer (that I know of) of my packages. My chains tend to be short.
Insult? No no no! I didn't mean to insult you at all, I was trying to find a good common ground to try explain why the Xcode 12.5 release fixes this issue without belabouring points you already know!
A swift package manager product before 12.5 will be embedded inside your target and statically linked.
If you have more than one target using that product, you will end up embedding it more than once, which creates duplicated symbols in your binary, which leads to undefined behaviour when calling that symbol at runtime (which Apple don't allow for apps on the AppStore - ironically Big Sur on M1 Macs has a lot of duplicated libraries for x86 and arm64 which will cause a warning about undefined behaviour when you call them - do as I say, not as I do).
What happens now in 12.5 onwards is those products will be dynamically linked, meaning there will be one copy of it in your binary, that each of your targets can call symbols on, which gets rid of the duplication and the potential for undefined behaviour.
OK. My apologies for being prickly. I guess I spend too much time on SO. I love electronic communications. They give us whole new realms, in which to explore rancor.
I understand. I have not encountered that. I'll look again. In most of my projects, the executables are test harnesses, and not all use SPM. Most of my dependencies are so small, that I might actually be better off directly linking in the source file from inside the package. I do that with the Carthage variants, but the static libs are so small, that I don't sweat it, and it makes life easier, all around.
I know that dylibs are fairly recent additions to SPM. One of the issues that I had with Carthage, was that I was constantly screwing up the signing. Since the libs were so small, I just said "Bugger this for a lark," and directly linked the source files. Since Carthage checks out in the project dir, this was easy. I use a separate derivedData directory, so it's not so straightforward to directly embed SPM source files. I haven't tried the new resources in SPM modules, yet.
Thanks for following up, and again, my apologies for overreacting.
> I think it's going to be another year or 2 before dropping CocoaPods entirely is a fair choice for libraries
For libraries this is probably true, but I would imagine that most apps could start on SPM from today and never need to introduce CocoaPods or Carthage (we did, ~1 year ago). There are certainly limitations, but they are disappearing fairly rapidly, and the advantage of simpler builds, no Ruby setup, simpler Xcode project structures, etc, are worthwhile.
Well, I won't go into the issues that prevent me from using CocoaPods, and why I'm not going to be publishing my libraries on them, from now on, but SPM has worked well for me. I am very careful about what I include in my projects. Most of my dependencies are fairly small ones that I wrote and published. Many are a single source file.
I don't see the libraries being embedded in my project, but maybe I need to use something like iMazing to look at the package.
Only annoyance for me with Carthage is needing to strip architectures out of the built frameworks in order for the app to be validated when uploading to App Store Connect. It's an awesome solution though, and much better than CocoaPods.
I'm deprecating my use of Cocoapods (for publishing -I never use them for my own software), in favor of SPM.
That said, it's clearly a labor of love, and filled an important niche for years.