Status of Portable Swift code

Portable Swift source code is so damn hard to do. Main problem is that OSX and Linux Swift is using different Foundation codebase.

Linux is using SwiftFoundation and OSX is using Foundation. What's the difference ?

Foundation vs SwiftFoundation

Foundation is written in Objective-C, it's complete and stable. SwiftFoundation on the other hand is partially implemented in Swift and unstable. Apple decided not publish their version of Foundation when open sourcing Swift. Since then, a lot of developers is trying to reverse engineer original Foundation and implement it in Swift - wouldn't be easier if Apple just show us the original implementation? yeah.

It may be today that Microsoft WinObjC implementation of Foundation is more complete than SwiftFoundation. Both projects have to deal with similar problem - reverse engineering, AKA guessing what's inside black box.


No problems on OSX, there is Xcode for that. To build project on Linux I have to manually use swiftc tool - it's like using gcc from hand to build a whole project.

There is experimental tool Swift Package Manager... but I can't use it easily. Can't use it because:

  • it's not part of Swift 2.2 stable release
  • it's not part of Swift 2.2 development release (March 1, 2016)
  • it's part of Swift 3.0 development release, and Swift 3.0 is not compatible with Swift 2.0 so much that I can't use the same codebase.


If tests success on OSX, doesn't mean it will success on Linux. Mostly because Foundation thing, and other language limitations that affect Linux mostly (not every feature is implemented on Linux, like casting Foundation types). Some functions are not implemented and just throw error in runtime - I can't figure out this part easily without actually running my code on Linux.

  • can't test on OSX with Xcode.
  • can't test with Swift 2.2 on Linux (March 1, 2016)
  • can't test with Swift 3.0 development release because it's different language than Swift 2.2 and source will not compile in the first place.

Platforms differences

It is obvious that platforms are different. Swift is not helping much with the variety of *nix systems. As for today, all I can do is spaghetti of #if os(...)

#if os(Linux)
    import Glibc
    import Darwin


Swift is really ok on OSX, but Linux port is highly experimental branch - nice to play for fun mostly. I wouldn't recommend to use it today. Maybe it will change with release of Swift 3.0, but then we'll look at Swift 4.0...

Today I'm releasing update to CryptoSwift and I don't know if it's working with Linux port of Swift... I don't really have tools to test it.