Swift Foundation 4.0 for Android

The Apple Swift foundation provides core functionality that is both essential as well as highly beneficial when writing mobile mobile applications of any decent size. Before long, the Swift Foundation was only partially available for Android.

In February, we completed 100% support of Swift Foundation for Android.

The Swift Foundation exposes a garden variety of useful functionality. It covers, among others, functionality for handling JSON and XML, extended String functionality, Collection support, Networking support as well as Time and Date functionality. Moreover, a UUID comes in handy.

Most of our users’ apps make heavy use of Swift Foundation, and therefore supporting it in our Swift Cross Platform solution SCADE was paramount for us. However, supporting all functionality on Android was quite a challenge:

One of the first serious challenges we encountered was libdispatch support. Many parts of the Swift foundation depend on libdispatch (think URLSession support) and it was vital that libdispatch was working well. Although the basic support was there, we had to extend the basic mechanism to be able to work and post closures to the main thread queue. We did this by extending the DispatchQueue class on Android.

Once done, we ran into our next challenge, the implementation of proper network support. The network support is based on libcurl, but the lack of proper root SSL certificates and fact that you cannot extract Android root certificates made it impossible to use it straight away. We had to skip libcurl and wrap theAndroid Network APIé. Puuh, Swift Foundation support is definitely not easy :-)

Quite a bit easier was the mapping of Swift Foundation system functions for directory management. Remember for instance NSTemporaryDirectory() ?Well, the iOS and Android directory structure differ, and therefore we had to use and map the Android API to retrieve the correct directories.

Finally, Timezone support was the last remaining challenge. iOS uses tzdata files for https://www.iana.org/time-zones time zone management, which are missing on Android. We added it to our Swift foundation to provide you with proper time zone support.

So how do we know that it worked. Well, we ported all of XCTest to Android and ran the test suite. We are quite happy with the results and another step in helping iOS Swift developer to reuse their code on Android.

Let us know if we missed anything. We wish you happy coding with our favorite language for mobile application development and are happy to answer your questions.

Your SCADE team
https://www.scade.io

Technical documentation: https://scade.readme.io
Download: https://www.scade.io/download