Upgrade to Pro — share decks privately, control downloads, hide ads and more …


January 28, 2016




January 28, 2016

More Decks by matuyuji

Other Decks in Programming


  1. Port of Apple's reference Swift toolchain to Android; doesn't quite

    work yet SwiftAndroid / swift forked from apple/swift
  2. /%,4XJGU"OESPJE curl -LO http://dl.google.com/android/ndk/android-ndk-r10e-linux- x86_64.bin chmod a+x android-ndk-r10e-linux-x86_64.bin ./android-ndk-r10e-linux-x86_64.bin >

    /dev/null export ANDROID_NDK_HOME=$HOME/android-ndk-r10e curl -LO https://github.com/SwiftAndroid/swift/releases/download/ swiftandroid-2016-01-06/swift_android_2016-01-06.tar.xz tar xf swift_android_2016-01-06.tar.xz export PATH=$PATH:$HOME/swiftandroid/bin
  3. $PNQJMF $ echo 'print("Hello world!")' > hello.swift $ swiftc-android hello.swift

    $ file hello hello: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, not stripped
  4. "OESPJE4%, sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get

    install -y libncurses5:i386 \ libstdc++6:i386 \ zlib1g:i386 sudo apt-get install -y openjdk-7-jdk curl -LO http://dl.google.com/android/android-sdk_r24.4.1- linux.tgz tar xf android-sdk_r24.4.1-linux.tgz export ANDROID_HOME=$HOME/android-sdk-linux echo y | $ANDROID_HOME/tools/android update sdk \ —-no-ui —-all \ —-filter platform-tools,tools,android-23,build-tools-23.0.2
  5. 4JNVMBUFPO.BD curl -LO http://dl.google.com/android/android-sdk_r24.3.4- macosx.zip unzip android-sdk_r24.3.4-macosx.zip cd android-sdk-macosx echo

    y | ./tools/android update sdk -a --no-ui —-filter \ android-23,sys-img-armeabi-v7a-android-23,platform-tools ./tools/android list targets ./tools/android create avd -n my_android23 -t 1 ./tools/emulator -avd my_android23 ./platform-tools/adb install swifthello-debug.apk
  6. 4XJGU)FMMPKBWB public class SwiftHello extends Activity { @Override protected void

    onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); loadNativeDependencies(); TextView myText = (TextView) findViewById(R.id.mytext); myText.setText("Result of swift return42() function is " + return42()); } private static void loadNativeDependencies() { System.loadLibrary("c++_shared"); System.loadLibrary("icudata"); System.loadLibrary("icui18n"); System.loadLibrary("icuuc"); // Swift System.loadLibrary("swiftCore"); System.loadLibrary("swiftGlibc"); // Our library System.loadLibrary("swifthello"); } public static native int return42(); }