Swift 5, 4.x, Xcode, and Carthage

I'm looking for some confirmation here. We use Carthage to manage third-party dependencies, and updating to Xcode 10.2 and Swift 5 I ran into a couple of issues. Carthage needed an update, that was done. After that, I had some errors building PromiseKit, but that problem seemed to magically disappear (I might've used xcode-select to change toolchains, not sure).

Then I thought I ran into issues where my newly-created Swift 5 project couldn't link against Swift 4.x-built Frameworks. The Swift 5 release notes say Swift 5 is not binary compatible with Swift 4, but does that mean a project can't link?

HOWEVER, I then built a brand-new project in Xcode 10.2, which defaulted to Swift 5, and used Carthage to build PromiseKit for it, and everything builds, links, and appears to execute just fine. Problem is, the Xcode project for PromiseKit is using Swift 4.x.

So, what's the expectation here? I'd imagine all linked Frameworks have to be Swift 5 in order to link, let alone reap the full benefits. Otherwise they'd all have their own copies of the runtime, wouldn't they?

Please forgive my incomplete understanding of all this. Thanks!

Yes, they're incompatible and everything will need to be rebuilt. Happily, this shouldn't be the case after 5.1 and module stability.

That's fine, as PromiseKit will build using the Swift 5 compiler, but in Swift 4.x mode, and all build products from the same version of the compiler are compatible.

You just need to build them all with the same version of the compiler.

3 Likes

Yes, I realized that I'm conflating the Swift 5 compiler with the Swift language version passed as an option. The former is required, the latter is not, am I right?

That's right. Something could probably be done to better disambiguate the two in discussions but I'm not sure what.

1 Like