@@ -43,51 +43,22 @@ To follow along with this guide, you'll need:
4343
4444## "Hello, world" on Android
4545
46- ### 1. Downloading (or building) the Swift Android stdlib dependencies
46+ ### 1. Building the Swift stdlib for Android
4747
48- You may have noticed that, in order to build the Swift stdlib for Linux, you
49- needed to ` apt-get install libicu-dev icu-devtools ` . Similarly, building
50- the Swift stdlib for Android requires the libiconv and libicu libraries.
51- However, you'll need versions of these libraries that work on Android devices.
52-
53- The steps are as follows:
54-
55- 1 . Ensure you have ` curl ` , ` autoconf ` , ` automake ` , ` libtool ` , and
56- ` git ` installed.
57- 2 . Clone the [ SwiftAndroid/libiconv-libicu-android] ( https://github.com/SwiftAndroid/libiconv-libicu-android )
58- project. From the command-line, run the following command:
59- ` git clone https://github.com/SwiftAndroid/libiconv-libicu-android.git ` .
60- 3 . From the command-line, run ` which ndk-build ` . Confirm that the path to
61- the ` ndk-build ` executable in the Android NDK you downloaded is displayed.
62- If not, you may need to add the Android NDK directory to your ` PATH ` .
63- 4 . Change directories into ` libiconv-libicu-android ` : ` cd libiconv-libicu-android `
64- 5 . Run the Swift build script: ` ./build-swift.sh `
65- 6 . Confirm that the various ` libicuXYZswift.so ` libraries are located in the
66- ` armeabi-v7a ` directory.
67-
68- ### 2. Building the Swift stdlib for Android
69-
70- Enter your Swift directory, then run the build script, passing paths to the
71- Android NDK, as well as the directories that contain the ` libicuucswift.so ` and
72- ` libicui18nswift.so ` you downloaded or built in step one:
48+ Enter your Swift directory, then run the build script, passing the path to the
49+ Android NDK:
7350
7451```
75- $ ARM_DIR=path/to/libiconv-libicu-android/armeabi-v7a
7652$ NDK_PATH=path/to/android-ndk-r23b
7753$ utils/build-script \
7854 -R \ # Build in ReleaseAssert mode.
7955 --android \ # Build for Android.
8056 --android-ndk $NDK_PATH \ # Path to an Android NDK.
8157 --android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64 or x86_64
82- --android-api-level 21 \ # The Android API level to target. Swift only supports 21 or greater.
83- --android-icu-uc ${ARM_DIR}/libicuucswift.so \
84- --android-icu-uc-include ${ARM_DIR}/icu/source/common \
85- --android-icu-i18n ${ARM_DIR}/libicui18nswift.so \
86- --android-icu-i18n-include ${ARM_DIR}/icu/source/i18n \
87- --android-icu-data ${ARM_DIR}/libicudataswift.so
58+ --android-api-level 21 # The Android API level to target. Swift only supports 21 or greater.
8859```
8960
90- ### 3 . Compiling ` hello.swift ` to run on an Android device
61+ ### 2 . Compiling ` hello.swift ` to run on an Android device
9162
9263Create a simple Swift file named ` hello.swift ` :
9364
@@ -121,7 +92,7 @@ This is exactly the error we want: the executable is built to run on an
12192Android device--it does not run on Linux. Next, let's deploy it to an Android
12293device in order to execute it.
12394
124- ### 4 . Deploying the build products to the device
95+ ### 3 . Deploying the build products to the device
12596
12697You can use the ` adb push ` command to copy build products from your Linux
12798environment to your Android device. If you haven't already installed ` adb ` ,
@@ -142,14 +113,6 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswi
142113$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp
143114```
144115
145- You will also need to push the icu libraries:
146-
147- ```
148- adb push /path/to/libicu-android/armeabi-v7a/libicudataswift.so /data/local/tmp
149- adb push /path/to/libicu-android/armeabi-v7a/libicui18nswift.so /data/local/tmp
150- adb push /path/to/libicu-android/armeabi-v7a/libicuucswift.so /data/local/tmp
151- ```
152-
153116In addition, you'll also need to copy the Android NDK's libc++:
154117
155118```
@@ -162,7 +125,7 @@ previous step:
162125$ adb push hello /data/local/tmp
163126```
164127
165- ### 5 . Running "Hello, world" on your Android device
128+ ### 4 . Running "Hello, world" on your Android device
166129
167130You can use the ` adb shell ` command to execute the ` hello ` executable on
168131the Android device:
@@ -182,7 +145,7 @@ Congratulations! You've just run your first Swift program on Android.
182145## Running the Swift test suite hosted on an Android device
183146
184147When running the test suite, build products are automatically pushed to your
185- device. As in part four , you'll need to connect your Android device via USB:
148+ device. As in part three , you'll need to connect your Android device via USB:
186149
1871501 . Connect your Android device to your computer via USB. Ensure that remote
188151 debugging is enabled for that device by following the official instructions:
@@ -198,10 +161,5 @@ $ utils/build-script \
198161 --android \ # Build for Android.
199162 --android-ndk ~/android-ndk-r23b \ # Path to an Android NDK.
200163 --android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64
201- --android-ndk-version 21 \
202- --android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
203- --android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
204- --android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
205- --android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/ \
206- --android-icu-data ~/libicu-android/armeabi-v7a/libicudata.so
164+ --android-ndk-version 21
207165```
0 commit comments