-
Notifications
You must be signed in to change notification settings - Fork 32
Getting started
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
run
export ANDROID_NDK_HOME=/path/to/ndk
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
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
Add swift to the PATH:
export PATH=$PATH:/path/to/swiftandroid/bin
Fix include paths in Bionic module:
swift androidfix
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
see the README of the gradle plugin. Basically,
git clone https://github.com/SwiftAndroid/swift-android-gradle.git
cd swift-android-gradle
./gradlew install
sudo apt-get install clang
git clone https://github.com/SwiftAndroid/swift-android-samples.git`
cd swift-android-samples/swifthello
./gradlew installDebug
You must have all the build prerequisites for Swift installed.
- On an Ubuntu 15.10 machine,
git checkout
the SwiftAndroid fork in the same directory as your Swift repository. It needs to be in the same position relative toswift-llvm
,swift-clang
, etc. - Clone libiconv-libicu-android and run the
build.sh
script. - Clone swift-android-extras and run the
copyicu.sh
script. - From within your Swift checkout, run
./utils/build-script -R
.
The icu-related steps are necessary because Android doesn't ship with libicu, which is used by Swift.
After building using the steps above, you may run the tests like so:
$ export LLVM_SOURCE_DIR="/path/to/llvm"
$ export SWIFT_BUILD_DIR="/path/to/build/dir/Ninja-ReleaseAssert/swift-linux-x86_64"
$ $LLVM_SOURCE_DIR/utils/lit/lit.py $SWIFT_BUILD_DIR/test-android-armv7
Your Android device must be connected and available via adb devices
in order to successfully run the tests.
You may encounter the following error when running tests:
--
Exit Code: 255
Command Output (stderr):
--
/home/modocache/GitHub/apple/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/armv7-none-linux-androideabi-ld: 2: exec: arm-linux-androideabi-ld.bfd: not found
clang-3.8: error: unable to execute command: No such file or directory
clang-3.8: error: linker command failed due to signal (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 255 (use -v to see invocation)
--
You should be able to work around this error by symlinking the ld
from your Android NDK:
$ ln -s \
$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.gold \
/usr/bin/armv7-none-linux-androideabi-ld.gold
Please report any issues to the issue tracker