You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can copy these executables and the SDK to [an emulator or a USB
66
-
debugging-enabled device with adb](https://github.com/apple/swift/blob/release/5.8/docs/Android.md#3-deploying-the-build-products-to-the-device),
64
+
debugging-enabled device with adb](https://github.com/apple/swift/blob/release/5.9/docs/Android.md#3-deploying-the-build-products-to-the-device),
67
65
or put them on an Android device with [a terminal emulator app like Termux](https://termux.dev/en/).
68
66
I test aarch64 with Termux so I'll show how to run the test runner there, but
69
-
the process is similar with adb, [as can be seen on the CI](https://github.com/buttaface/swift-android-sdk/blob/5.8/.github/workflows/sdks.yml#L326).
67
+
the process is similar with adb, [as can be seen on the CI](https://github.com/finagolfin/swift-android-sdk/blob/5.9/.github/workflows/sdks.yml#L328).
70
68
71
69
Copy the test executables to the same directory as the SDK:
72
70
```
@@ -79,10 +77,10 @@ uname -m # check if you're running on the right architecture, should say `aarch6
The most commonly needed change is to simply import Glibc for Android too (while
101
103
Bionic is the name of the C library on Android, currently Swift uses the name
102
-
`Glibc` as a placeholder for all non-Darwin, non-Windows C libraries), so add
104
+
`Glibc` as a placeholder for most non-Darwin, non-Windows C libraries), so add
103
105
or change these two lines for Android:
104
106
```
105
107
#if canImport(Glibc)
@@ -115,10 +117,13 @@ refer to any FILE pointers like this](https://github.com/apple/swift-tools-suppo
115
117
#if os(Android)
116
118
typealias FILEPointer = OpaquePointer
117
119
```
120
+
121
+
# Building an Android app with Swift
122
+
118
123
Some people have reported an issue with using the libraries from this SDK in
119
124
their Android app, that the Android toolchain strips `libdispatch.so` and
120
125
complains that it has an `empty/missing DT_HASH/DT_GNU_HASH`. You can [work
121
-
around this issue by adding the following to your `build.gradle`](https://github.com/buttaface/swift-android-sdk/issues/67#issuecomment-1227460068):
126
+
around this issue by adding the following to your `build.gradle`](https://github.com/finagolfin/swift-android-sdk/issues/67#issuecomment-1227460068):
122
127
```
123
128
packagingOptions {
124
129
doNotStrip "*/arm64-v8a/libdispatch.so"
@@ -127,16 +132,22 @@ packagingOptions {
127
132
}
128
133
```
129
134
130
-
# Building the Android SDKs
135
+
Note that the FoundationNetworking and FoundationXML libraries won't actually
136
+
run on Android with this SDK, as their dependencies libcurl and libxml2 have other
137
+
library dependencies that aren't included. If you want to use either of these
138
+
separate Foundation libraries, you will have to track down those other libcurl/xml2
139
+
dependencies and include them yourself.
131
140
132
-
Download the Swift 5.8.1 compiler and Android NDK 25c as above. Check out this
141
+
# Building the Android SDKs from source
142
+
143
+
Download the Swift 5.9 compiler and Android NDK 25c as above. Check out this
133
144
repo and run
134
-
`SWIFT_TAG=swift-5.8.1-RELEASE ANDROID_ARCH=aarch64 swift get-packages-and-swift-source.swift`
145
+
`SWIFT_TAG=swift-5.9-RELEASE ANDROID_ARCH=aarch64 swift get-packages-and-swift-source.swift`
135
146
to get some prebuilt Android libraries and the Swift source to build the SDK. If
136
-
you pass in a different tag like `swift-DEVELOPMENT-SNAPSHOT-2023-09-17-a`
147
+
you pass in a different tag like `swift-DEVELOPMENT-SNAPSHOT-2023-09-22-a`
137
148
for the latest Swift trunk snapshot and pass in the path to the corresponding
138
-
official prebuilt Swift toolchain to `build-script` below, you can build a Swift
139
-
trunk SDK too, as seen on the CI.
149
+
prebuilt Swift toolchain to `build-script` below, you can build a Swift trunk
150
+
SDK too, as seen on the CI.
140
151
141
152
Next, apply a patch to the Swift source, `swift-android.patch` from
142
153
this repo, which adds a dependency for the Foundation core library in this
@@ -145,14 +156,14 @@ Android SDK:
145
156
git apply swift-android.patch
146
157
```
147
158
148
-
After making sure [needed build tools like python 3, CMake, and ninja](https://github.com/apple/swift/blob/release/5.8/docs/HowToGuides/GettingStarted.md#linux)
159
+
After making sure [needed build tools like python 3, CMake, and ninja](https://github.com/apple/swift/blob/release/5.9/docs/HowToGuides/GettingStarted.md#linux)
149
160
are installed, run the following `build-script` command with your local paths
The libcurl and libxml2 packages are [only needed for the FoundationNetworking
211
-
and FoundationXML libraries respectively](https://github.com/apple/swift-corelibs-foundation/blob/release/5.8/Docs/ReleaseNotes_Swift5.md),
222
+
and FoundationXML libraries respectively](https://github.com/apple/swift-corelibs-foundation/blob/release/5.9/Docs/ReleaseNotes_Swift5.md),
212
223
so you don't have to deploy them on the Android device if you don't use those
213
-
extra Foundation libraries.
214
-
215
-
I simply include all four libraries since there's currently no way to disable
216
-
building them in the CMake configuration, but they won't actually run on
217
-
Android with this SDK, as libcurl and libxml2 have other library dependencies
218
-
that aren't included. If you want to use either of these separate Foundation
219
-
libraries, you will have to track down those other libcurl/xml2 dependencies and
220
-
include them yourself.
224
+
extra Foundation libraries. I simply include all four libraries since there's
225
+
currently no way to disable building them in the CMake configuration.
221
226
222
227
The libicu dependency can be [cross-compiled for Android from scratch using
223
228
these instructions](https://github.com/apple/swift/blob/release/5.5/docs/Android.md#1-downloading-or-building-the-swift-android-stdlib-dependencies)
224
229
instead, so this Swift SDK for Android could be built without using
225
230
any prebuilt Termux packages, if you're willing to put in the effort to
226
231
cross-compile them yourself, for example, against a different Android API.
227
232
228
-
Finally, it gets [the 5.8.1 source](https://github.com/apple/swift/releases/tag/swift-5.8.1-RELEASE)
229
-
tarballs for five Swift repos and renames them to `llvm-project/`, `swift/`,
230
-
`swift-corelibs-libdispatch`, `swift-corelibs-foundation`, and
231
-
`swift-corelibs-xctest`, as required by the Swift`build-script`, and creates
232
-
an empty directory, `mkdir cmark`.
233
+
Finally, it gets [the 5.9 source](https://github.com/apple/swift/releases/tag/swift-5.9-RELEASE)
234
+
tarballs for seven Swift repos and renames them to `llvm-project/`, `swift/`,
0 commit comments