|
1 | 1 | # Swift cross-compilation SDKs for Android |
2 | 2 |
|
3 | | -To build with an SDK, first download [the latest Android NDK 21d] |
4 | | -(https://developer.android.com/ndk/downloads) and [Swift compiler](https://swift.org/download/#releases). |
5 | | -Unpack these archives and the SDK. |
| 3 | +To build with an SDK, first download [the latest Android NDK 21d](https://developer.android.com/ndk/downloads) |
| 4 | +and [Swift compiler](https://swift.org/download/#releases). Unpack these archives |
| 5 | +and the SDK. |
6 | 6 |
|
7 | 7 | The SDK will need to be modified with the path to your NDK and Swift compiler |
8 | 8 | in the following ways: |
9 | 9 |
|
10 | | -1. Change all paths in swift-android-aarch64-24-sdk/usr/lib/swift/android/aarch64/glibc.modulemap |
11 | | -from /home/butta/swift/android-ndk-r21d to the path to your NDK. |
| 10 | +1. Change all paths in `swift-android-aarch64-24-sdk/usr/lib/swift/android/aarch64/glibc.modulemap` |
| 11 | +from `/home/butta/swift/android-ndk-r21d` to the path to your NDK. |
12 | 12 |
|
13 | | -2. Change the symbolic link at swift-android-aarch64-24-sdk/usr/lib/swift/clang |
| 13 | +2. Change the symbolic link at `swift-android-aarch64-24-sdk/usr/lib/swift/clang` |
14 | 14 | to point to the clang headers next to your swift compiler, ie |
15 | 15 |
|
16 | | -ln -sf /home/yourname/swift-5.3.1-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0 swift-android-aarch64-24-sdk/usr/lib/swift/clang |
17 | | - |
| 16 | +``` |
| 17 | +ln -sf /home/yourname/swift-5.3.1-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0 |
| 18 | +swift-android-aarch64-24-sdk/usr/lib/swift/clang |
| 19 | +``` |
18 | 20 | Finally, modify the cross-compilation JSON file in this repo similarly: |
19 | 21 |
|
20 | | -1. All paths to the NDK should change from /home/butta/swift/android-ndk-r21d |
| 22 | +1. All paths to the NDK should change from `/home/butta/swift/android-ndk-r21d` |
21 | 23 | to the path to your NDK. |
22 | 24 |
|
23 | | -2. The path to the compiler should change from /home/butta/swift/swift-5.3.1-RELEASE-ubuntu20.04 |
| 25 | +2. The path to the compiler should change from `/home/butta/swift/swift-5.3.1-RELEASE-ubuntu20.04` |
24 | 26 | to the path to your Swift compiler. |
25 | 27 |
|
26 | | -3. The path to the Android SDK should change from /home/butta/swift/swift-android-aarch64-24-sdk |
| 28 | +3. The path to the Android SDK should change from `/home/butta/swift/swift-android-aarch64-24-sdk` |
27 | 29 | to the path to where you unpacked the Android SDK. |
28 | 30 |
|
29 | 31 | Now you're ready to cross-compile a Swift package with the cross-compilation |
30 | 32 | JSON config: |
31 | | - |
| 33 | +``` |
32 | 34 | swift build --build-tests --enable-test-discovery --destination ~/swift-android-sdk/android-aarch64.json |
| 35 | +``` |
0 commit comments