Can we create a static library using Swift files

We want to create a static library to be distributed for third party developers.

In XCode 8.2 when attempted gives error as below

" Swift is not supported for static Llbraries"

Is it Dynamic framework is the only way? Any idea when it would be possible to create static library?

Replies

Is it Dynamic framework is the only way?

Yes. And no. Realistically it’s not feasible to distribute Swift libraries in binary form right now. For this to even have a chance of working your client will have to use exactly the same version of Swift as you’re using. And even then I’m concerned about the Swift module side of things.

Any idea when it would be possible to create static library?

I’m not about to talk about The Future™. I will say that this is being actively discussed on swift-evolution right now.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

There may be other technical reasons why Xcode does not support Swift-based static libraries, but the big reason is that every Swift object file used in an app (whether the main app target or a framework) must currently be compiled with the exact same Swift version. That means you cannot currently pass around a static library (or a compiled framework either) between different projects unless you can guarantee that it is the same version of Xcode and the same version of Swift. Because of that limitation, compiled libraries are not very useful.


For now, you should think of compiling every piece of Swift code that your app uses, no matter which target, as part of building your app.


This restriction will exist until the permanent ABI is done, which is planned for Swift 4. We might see Swift 4 at WWDC in June, or at the next major OS releases (presumably about Septemer/October), but there is no guarantee on the timing. It will be done when it is done.

You beat me to the punch, because I was in "invalid characters in post" ****. Turns out, I had the same problem someone else reported a few days ago, that using the word spelled g - o - a - l causes posts to be rejected. Any chance you can find an appropriate authority to pass this problem onto? Actual forum moderaters seem to exist only in a fantasy world.

Turns out, I had the same problem someone else reported a few days ago, that using the word spelled g - o - a - l causes posts to be rejected.

Indeed it does. If you look at my posts, you’ll see I subtly tweak the word to avoid this.

Any chance you can find an appropriate authority to pass this problem onto?

Yeah, I’ve reported this multiple times before without any success. I’ve just checked my previous reports and they’ve been closed with unsatisfactory resolutions, so I’ve filed yet another one (INC063510486).

This restriction will exist until the permanent ABI is done, which is planned for Swift 4.

You seem to have missed this memo. Also, I want to make sure you’ve seen the swiftmodule stability section of this post. Finally, the Swift ABI Stability Manifesto is super interesting.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Turns out, I had the same problem someone else reported a few days ago, that using the word spelled g - o - a - l causes posts to be rejected.

And lo! it’s fixed. You are now free to post the word goal with restrictions. Yay!

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"