Hello,
An often cited problem for using Swift on other platforms is the effort required to get everything working together. To help address this barrier to entry, I have been exploring some options to reduce the initial friction for development on other targets (e.g. android, Linux, etc).
Now, I realize that some of my choices may be controversial for some, so, I would like to preface this as I am NOT advocating that this be the only development, merely an option for those that would like to use it. I personally prefer to develop locally and use my editor of choice, so I can completely understand why some may be frustrated with some of the tradeoffs made here. Please note that I am not trying to remove those options, merely provide an alternative which others can explore if it suits them.
I have been exploring the idea of creating a pre-configured docker image using Ubuntu 18.04 which is prepackaged with a complete toolchain for C/C++/Swift - clang, clang-format, lld, lldb, etc. It also has a copy of VSCode installed (as a build of coder.com's CodeServer). This means that what you have is a headless server instance that has all the necessary pieces in place - VSCode, toolchain, tools and pre-configured. There are a few volumes which would be "well-known" that are expected to be supplied by the user - locations for the source code and binary artifact. This allows having the ability to have a self-contained toolchain without having to worry about the user's setup. Because everything is self-contained, upgrades/tests are simply a matter of swapping out the container and due to the pre-configured nature of it, do not require adjusting much.
I have been playing around a bit with this, and this largely amounts to a workflow of the following:
docker run -v /SourceCache:/SourceCache -v /BinaryCache:/BinaryCache compnerd/swift
- launch chrome
- navigate to
http://localhost:8080
.
I've been able to build projects in the docker image, and it would be possible to pre-configure a number of additional cross-compilation targets as well simplifying the build setup for e.g. android.
This is something which can easily expand in scope and I do not think that I have enough time to grow this to something more finessed, however, the configuration for this is something which I have on GitHub, and welcome PRs to improve it. I also have some prebuilt images on DockerHub.
The current items which are missing which I would like to see added to this image is llbuild, s-p-m, and SourceKit-LSP. I would like to have SourceKit-LSP also pre-configured so that it is possible to have semantic completion enabled by default.
I welcome PRs to help improve this experience. Hopefully this will reduce the barrier to entry and make it easier for others to get started with developing with Swift.
Happy Thanksgiving!
Saleem