Distributable Swift code in binary form

This arises in regard to a question over on the Apple developer forums. Given this scenario:

Assume there is a developer A who wishes to distribute a library (say, for accessing A's web service) to client developers to use in their applications (that, say, access A's web service).

I have these questions:

[a] Is there currently any mechanism by which A can distribute any kind of component containing already-compiled Swift code?

[b] If the answer is "no", does the answer change at all if the client can be restricted to the same version of Xcode and Swift as A?

By component, I mean any combination of frameworks or static libraries that can be presented to clients as a single item to add to the client's Xcode project.

Based on what @eskimo has said on the subject, it seems like the answers are "no" at least most of the time.

If the answers are "no" all of the time, this seems like a pretty big deal for developers who are not in a position, for business reasons, to publish all of their source code.

Here's the thread where this discussion is ongoing:


(FWIW, it's long mainly because I kept answering the wrong question or giving the wrong answer. I'd like to be able to stop doing that. @eskimo appears to have said that an app target cannot use a Swift-based framework unless it was built as a framework target in the same project as the app — but I might have misunderstood.)

Thanks for the link. It kind of sharpens the focus on the problematic question. Pasting the relevant pieces:

In response to my suggestion: "…ship a framework for a specific Xcode version (or, usually, a couple of Xcode versions), and require users to be on a version you support…"

@eskimo said: "Be careful. […] Xcode’s framework build products (for Swift) were not designed to be shared like this…"

Your linked blog says: "Swift binary frameworks are possible and do exist."

The last two statements are not mutually consistent. Together, they say that Swift binary frameworks both can and cannot be shipped.

They exist, but you have to ship a new framework version for every new Xcode and/or Swift compiler build. Also user's toolchain version has to match the version that was used to compile the framework/library. I'm mentioning libraries here, because this is the case on Linux too, where I don't think it's fair to call dynamic libraries as "frameworks".

Again, thanks for the response, but @eskimo says no. At least, I think that's what the above quote means. Maybe we have to wait till @eskimo can clarify.

Meantime, there's now also this:


Anyone want to tackle that?