Skip to content
zhuowei edited this page Jan 7, 2016 · 14 revisions

Install required software

You need Ubuntu 15.10 64-bit to run the prebuilt version. (Other versions of Linux are not supported at this time)

If you don't have Android SDK's ADB, sudo apt-get install android-tools-adb

Install Android NDK - version r10e Linux 64-bit

Configure NDK and linker

run export ANDROID_NDK_HOME=/path/to/ndk

Install and run SwiftAndroid

Extract the downloaded file:

tar xf swift_android_2015-12-12.tar.xz

Write a simple Hello World program, and save it as hello.swift.

Now, try building the executable:

swiftandroid/bin/swiftc-android hello.swift

Run the resulting executable

Push the executable and all its dependent libraries to the Android device.

There's a script that will do this for you: run

swiftandroid/bin/swift-android-push hello

to push hello and the libraries to /data/local/tmp

Run the executable, passing LD_LIBRARY_PATH to where the executable and libraries are saved

adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/hello

Extra setup

Add swift to the PATH:

export PATH=$PATH:/path/to/swiftandroid/bin

Fix include paths in Bionic module:

swift androidfix

Building APKs

Install Android SDK

follow instructions on Google site. Basically

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386
sudo apt-get install openjdk-7-jdk`

Then download and install the Android SDK from http://developer.android.com/sdk/installing/index.html?pkg=tools

After installing, export the location of the Android SDK:

export ANDROID_HOME=/path/to/android-sdk-linux

Install Gradle plugin

see the README of the gradle plugin. Basically,

git clone https://github.com/SwiftAndroid/swift-android-gradle.git
cd swift-android-gradle
./gradlew install

Make sure you have Clang installed

sudo apt-get install clang

Try building the sample APK:

git clone https://github.com/SwiftAndroid/swift-android-samples.git`
cd swift-android-samples/swifthello
./gradlew installDebug

Issues, problems?

Please report any issues to the issue tracker

Clone this wiki locally