Skip to content

Latest commit

 

History

History
84 lines (59 loc) · 3.22 KB

HowToUse.md

File metadata and controls

84 lines (59 loc) · 3.22 KB

Swift Toolchain for Android

This repo provides toolchain than can compile swift packages to .so files that can be use with NDK in Android.

GitHub action files are used to build the build tools. Here are the steps to follow if you want to build it locally

Requirements

  • macOS 12
  • Xcode 13
  • Android Studio 2020.3.1
  • Android NDK (See version number in file NDK_VERSION in the root of this repository)
  • Node 14.17.3 (node -v). Newer versions may also work, but not tested.
  • CMake 3.21.2 (cmake --version)
  • Ninja 1.10.2 (ninja --version)
  • autoconf 2.71 (autoconf --version)
  • aclocal 1.16.4 (aclocal --version)
  • glibtool 2.4.6 (glibtool --version)
  • pkg-config 0.29.2 (pkg-config --version)

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 Action artifact.

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.

  7. To skip the macOS cannot verify that this app is free from malware. popup(s) for all the files you can run this script in extracted swift-android-toolchain folder

    cd swift-android-toolchain
    find . -type f -name "*.*" -exec xattr -d com.apple.quarantine $(echo {}) \;
    find * -type f -name "*" -exec xattr -d com.apple.quarantine $(echo {}) \;