vgorloff / swift-everywhere-toolchain

Automated workflow to compile Swift Toolchain, for making Android apps with Swift.
MIT License
85 stars 25 forks source link
android android-ndk icu swift swift-corelibs-dispatch swift-corelibs-foundation

swift-everywhere-toolchain

My Town

This Open source project won't be updated until Kremlin will stop war in Ukraine and repair damages made in towns: Irpin, Bucha, Gostomel. If this won't happen during next 6 months (until 1 September 2022), then this project will be removed from public space.

Town of Irpin after Airstrike

See also:

Requirements

Important

Keep tools like CMake and ninja up to date.

Using pre-built toolchain

Build of complete toolchain takes ~1.5h. Instead of building it you can just download and use already pre-built package from Releases page.

Setup and Build

  1. Install CMake, Ninja, Autotools and git-lfs. Check that all requirements are installed.

    brew install cmake ninja autoconf automake libtool pkg-config git-lfs
    which cmake
    which ninja
    which autoconf
    which aclocal
    which glibtool
    which pkg-config
    which git-lfs
  2. Make sure that Xcode Build Tools properly configured.

    xcode-select --print-path
  3. Clone this repository.

    git clone https://github.com/vgorloff/swift-everywhere-toolchain.git
    cd swift-everywhere-toolchain
  4. Create a symbolic link to NDK installation directory.

    sudo mkdir -p /usr/local/ndk
    sudo ln -vsi ~/Library/Android/sdk/ndk/$VERSION /usr/local/ndk/$VERSION

    The placeholder $VERSION needs to be replaced with a version mentioned in file NDK_VERSION at the root of cloned repository.

  5. Start a build.

    node main.js
  6. Once the build completed, toolchain will be saved to folder ToolChain/swift-android-toolchain and compressed into archive ToolChain/swift-android-toolchain.tar.gz.

Usage

Please refer file Assets/Readme.md to see how to compile Swift files or build Swift packages using Toolchain.

Sample Projects

Sample projects can be found in a separate swift-everywhere-samples repository. Please look into Readme.md in that repository to get information about how to configure and build sample projects.