# Android API minimum for the Swift SDK for Android

**URL:** <https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874>\
**Category:** Android\
**Tags:** android\
**Created:** [October 27, 2025, 1:00am UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874 "2025-10-27T01:00:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcprux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/marcprux/32/12098_2.png) [@marcprux](https://forums.swift.org/u/marcprux)\
**Post date:** [October 27, 2025, 1:00am UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/1 "2025-10-27T01:00:26Z")

</div>

With the [official announcement](https://www.swift.org/blog/nightly-swift-sdk-for-android/) of the Swift SDK for Android, the Android workgroup has fielded some questions about the minimum supported Android version for Swift. Currently we are supporting Android API 28 (a.k.a. **[Android 9](https://developer.android.com/about/versions/pie)**, version code P, codename "Pie"). Released in 2018, it is supported by 91.7% of active Android devices according to the estimates at [apilevels.com](https://apilevels.com).

The choice of minimum supported API has been largely pragmatic. Older versions lack some APIs that are needed by various components of the core frameworks. In particular, `posix_spawn` was added in API 28, and as discussed at [https://github.com/swiftlang/github-workflows/issues/83](https://github.com/swiftlang/github-workflows/issues/83), we settled on that minimum level for expedience.

That being said, there are paths to supporting even older versions of Android, especially now that we will be able to conditionally gate APIs using `#available` clauses for Android levels (thanks to @madsodgaard for [https://github.com/swiftlang/swift/pull/84574](https://github.com/swiftlang/swift/pull/84574)!)

We have heard of custom Swift SDKs builds being created for older API levels, and we would like to survey the community about whether they have the need to support older Android versions, along with any details they can share about their target environment. This might be because they would like to use Swift on bespoke Android hardware that is stuck on older API levels, or simply because they want/need to be able to target an even wider swath of Android consumers than the ~92% coverage provided by API 28. Android powers not just phones and tablets, but a huge range of consumer and industrial devices, and we do not presume to know all the scenarios where developers might benefit from being able to develop in Swift for Android.

In any case, we want to hear from you! Feel free to chime in on this thread about your ideal Android minimums, or reach out directly to the team by messaging [@android-workgroup](https://forums.swift.org/g/android-workgroup) on the Swift Forums.

---

<div class="post-metadata">

**Author:** ![keeshux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/keeshux/32/40485_2.png) [@keeshux](https://forums.swift.org/u/keeshux)\
**Post date:** [October 27, 2025, 6:25am UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/2 "2025-10-27T06:25:43Z")

</div>

Hi Marc,

I personally find a worldwide 8.3% to be still pretty relevant, given that this could be much higher in Africa or countries like India, to name one. I noticed this change in the recent releases of the SDK with Swift 6.2, but sticking to 6.1 has allowed me to keep support down to API 24, for others reading.

At the end of the day, it really depends on the nature of the applications, and while I find the % significant for my case, I don’t think most developers will notice.

Still curious to hear other perspectives on the matter.

Keep up the good work!

---

<div class="post-metadata">

**Author:** ![madsodgaard](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/madsodgaard/32/43318_2.png) [@madsodgaard](https://forums.swift.org/u/madsodgaard)\
**Post date:** [October 27, 2025, 7:29am UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/3 "2025-10-27T07:29:19Z")

</div>

I do understand the rationale behind API 28 minimum. But, we also need to support API 23+ for our use case. We unfortunately do not have the luxury of upgrading Android versions, as we run it on "custom" hardware, i.e. non-phones, as well as Android phones.

Our current plan is to maintain a [fork of finagolf's repo, modified to support API 23+](https://github.com/madsodgaard/swift-android-sdk), unless the working group decides to distribute the official SDK with lower versions available. API 23 is old, and there are a lot of APIs that were first added in 24 even, so maybe this is too much to ask... However, maybe the above fork can be an inspiration for what is "missing", and at least just a "fallback" for people requiring legacy support.

However, I do still think it's relevant to talk about API 24 minimum.

You mention that the main issue is probably `posix_spawn`. However, from what I could find the spawn APIs are only used in the new `Subprocess` API from Foundation and the old `Process`. I might be wrong on this one, so please correct me if it is also used in other parts of Swift. I would argue that this API is probably not the most common use case for the Android SDK, and it can now even be safely guarded using the Android availability checking added to Swift.

---

<div class="post-metadata">

**Author:** ![keeshux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/keeshux/32/40485_2.png) [@keeshux](https://forums.swift.org/u/keeshux)\
**Post date:** [October 27, 2025, 8:33am UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/4 "2025-10-27T08:33:10Z")

</div>

> [@madsodgaard](#):
>
> You mention that the main issue is probably `posix_spawn`. However, from what I could find the spawn APIs are only used in the new `Subprocess` API from Foundation and the old `Process`. I might be wrong on this one, so please correct me if it is also used in other parts of Swift. I would argue that this API is probably not the most common use case for the Android SDK, and it can now even be safely guarded using the Android availability checking added to Swift.

IMHO this approach is important for Swift evolution in general. Aside from the inherent issue of Android API support, if we're giving up API 24 for something that only a small % of developers use _in Swift_ (first time I hear of the Subprocess API), then I 100% lean towards conservative availability checks. If supporting API 24 increases the complexity of the build system, that's a different story, but I don't know the internal extent of the change to draw any conclusions.

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [October 27, 2025, 2:13pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/5 "2025-10-27T14:13:43Z")

</div>

> [@madsodgaard](#):
>
> You mention that the main issue is probably `posix_spawn`. However, from what I could find the spawn APIs are only used in the new `Subprocess` API from Foundation and the old `Process`. I might be wrong on this one, so please correct me if it is also used in other parts of Swift. I would argue that this API is probably not the most common use case for the Android SDK, and it can now even be safely guarded using the Android availability checking added to Swift.

Yes, it is not used much in a Swift SDK, just there and in Testing for exit tests. As you and @etcwilde noted, it wouldn't take much more to integrate Bionic back to API 23 or 24 also, as I'm well aware since my Android SDK bundle has long supported API 24.

The problem is that before you brought up this API 23 support issue elsewhere for the first time a month ago, nobody in the workgroup seemed to really want to go that far back and do the work to fix the remaining holes. Then, there is of course the possible `futex` issue a workgroup member mentioned, where they saw crashes before API 29 because Swift 6 started using that system call in the stdlib and he said those older linux kernels didn't have it.

Another consideration I just remembered is that Android didn't add native Thread-Local Storage (TLS) till API 29, so we are actually compiling the one TLS variable in the Swift stdlib with emulated TLS, to support that older API.

However, as I pointed out to you then, even those Process-related APIs in Foundation don't really need `posix_spawn_*` in Bionic, as there are polyfills in Foundation for most of them, for all but [these more newly added ones](https://github.com/swiftlang/swift-corelibs-foundation/pull/2928).

If you and whoever you're working with want to push the official SDK back to API 23, by doing that work to fix or avoid the few remaining issues, we can certainly consider it.

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [October 27, 2025, 2:56pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/6 "2025-10-27T14:56:45Z")

</div>

> [@Finagolfin](#):
>
> Yes, it is not used much in a Swift SDK, just there and in Testing for exit tests.

I'll point out we don't support exit tests on Android, at least not yet. (But I'm happy to work with you to get them up and running—it shouldn't be _hard_ to support them.)

**Edit:** [[WIP, DNM] Enable exit tests on Android API level 28 and newer. by grynspan · Pull Request #1381 · swiftlang/swift-testing · GitHub](https://github.com/swiftlang/swift-testing/pull/1381)

---

<div class="post-metadata">

**Author:** ![barnard-b](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/barnard-b/32/10313_2.png) [@barnard-b](https://forums.swift.org/u/barnard-b)\
**Post date:** [October 27, 2025, 9:29pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/7 "2025-10-27T21:29:26Z")

</div>

> [@madsodgaard](#):
>
> I do understand the rationale behind API 28 minimum. But, we also need to support API 23+ for our use case. We unfortunately do not have the luxury of upgrading Android versions, as we run it on "custom" hardware, i.e. non-phones, as well as Android phones.

Probably not typical, but most of the apps I work on also have a minimum of API 23 for marketshare.

---

<div class="post-metadata">

**Author:** ![ahti](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ahti/32/604_2.png) [@ahti](https://forums.swift.org/u/ahti)\
**Post date:** [October 27, 2025, 10:21pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/8 "2025-10-27T22:21:58Z")

</div>

Just as another data point, at my work we would be interested in bringing some of our Swift code into an Android app currently requiring API level 24.

---

<div class="post-metadata">

**Author:** ![marcprux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/marcprux/32/12098_2.png) [@marcprux](https://forums.swift.org/u/marcprux)\
**Post date:** [October 28, 2025, 4:40am UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/9 "2025-10-28T04:40:33Z")

</div>

Thanks to everyone that has chimed in so far. This is very valuable feedback for us, so keep it coming!

As an experiment, I did a quick patching-out of the offending `posix_spawn_*` calls (in [Android API 24 by marcprux · Pull Request #16 · swift-android-sdk/swift-docker · GitHub](https://github.com/swift-android-sdk/swift-docker/pull/16)), and the SDK does indeed [build](https://github.com/swift-android-sdk/swift-docker/actions/runs/18861601682/job/53820869953) for API 24 and pass some testing. So we might want to consider moving the official supported level down to 24. I'll add it to the agenda of the next workgroup meeting and we can discuss further.

P.S. for completeness, I did also try API 23, but hit some more significant [build failures](https://github.com/swift-android-sdk/swift-docker/actions/runs/18863371112). If this is a compelling enough target for anyone, they might help seek workarounds for the missing symbols like `getgrnam_r` and `getgrgid_r`, as well as any subsequent shortcomings this target might encounter.

---

<div class="post-metadata">

**Author:** ![marcprux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/marcprux/32/12098_2.png) [@marcprux](https://forums.swift.org/u/marcprux)\
**Post date:** [October 29, 2025, 3:31pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/10 "2025-10-29T15:31:43Z")

</div>

There seem to be enough interest in supporting older API levels that I managed to get a custom build working (in [Android API 23 by marcprux · Pull Request #16 · swift-android-sdk/swift-docker · GitHub](https://github.com/swift-android-sdk/swift-docker/pull/16)). You can install and experiment with the _unofficial_ SDK build at [https://github.com/swift-android-sdk/swift-android-sdk/releases/tag/DEVELOPMENT-SNAPSHOT-2025-10-16-a](https://github.com/swift-android-sdk/swift-android-sdk/releases/tag/DEVELOPMENT-SNAPSHOT-2025-10-16-a).

I'm definitely interested in hearing the results of testing against actual devices with API 23 or 24. I haven't even tested against an emulator at those levels, and don't have any device that goes back before API 28.

> **[Release DEVELOPMENT-SNAPSHOT-2025-10-16-a · swift-android-sdk/swift-android-sdk](https://github.com/swift-android-sdk/swift-android-sdk/releases/tag/DEVELOPMENT-SNAPSHOT-2025-10-16-a)**
>
> WarningThis is an experimental build of the Swift SDK for Android that supports back to Android API 23, as discussed at https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/...

---

<div class="post-metadata">

**Author:** ![madsodgaard](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/madsodgaard/32/43318_2.png) [@madsodgaard](https://forums.swift.org/u/madsodgaard)\
**Post date:** [October 29, 2025, 4:20pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/11 "2025-10-29T16:20:34Z")

</div>

Nice! For API 23, you would probably also want to add shims for ifaddrs and change the FILE pointer for it to be actually useable. You check how I do it in repo linked further up. I’d be happy to help out, if the workgroup decides that this is something we officially want to support:)

---

<div class="post-metadata">

**Author:** ![marcprux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/marcprux/32/12098_2.png) [@marcprux](https://forums.swift.org/u/marcprux)\
**Post date:** [October 29, 2025, 4:50pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/12 "2025-10-29T16:50:36Z")

</div>

Thanks for the offer to help, @madsodgaard — that would be appreciated.

I would also love to hear whether this SDK works for your particular device target…

---

<div class="post-metadata">

**Author:** ![purpln](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/purpln/32/42536_2.png) [@purpln](https://forums.swift.org/u/purpln)\
**Post date:** [October 29, 2025, 7:23pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/13 "2025-10-29T19:23:15Z")

</div>

I've also faced the need for an even lower NDK\* version (21). My initial approach was to back-port the missing functions, but if I remember correctly it only worked for ndk 23 and I ran into another [problem](https://github.com/finagolfin/swift-android-sdk/issues/221). I realized that I need a workaround similar to what you made in your fork. I'm also working with a non-phone integrated device that has very limited hardware (it even misses a screen).

Returning to the main topic, for me, the lower the supported version, the better. If an `@available` check is coming soon, why not simply mark all the relevant APIs - for example, `Process` from Foundation and `Subprocess` ?

> **part of back-porting that helped**
>
> ```swift
> #include <bits/struct_file.h>
> 
> struct __sFILE;
> typedef struct __sFILE FILE;
> 
> extern FILE* stdin;
> extern FILE* stdout;
> extern FILE* stderr;
> 
> #include <xlocale.h>
> 
> float strtof_l(const char *nptr, char **endptr, locale_t loc);
> double strtod_l(const char *nptr, char **endptr, locale_t loc);
> 
> ```
> 
> ```swift
> extern FILE __sF[];
> 
> FILE* stdin = &__sF[0];
> FILE* stdout = &__sF[1];
> FILE* stderr = &__sF[2];
> 
> #include <stdlib.h>
> 
> float strtof_l(const char *nptr, char **endptr, locale_t loc) {
> return strtof(nptr, endptr);
> }
> 
> double strtod_l(const char *nptr, char **endptr, locale_t loc) {
> return strtold(nptr, endptr);
> }
> 
> ```

\*API level  
Thanks's for correcting @marcprux

---

<div class="post-metadata">

**Author:** ![marcprux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/marcprux/32/12098_2.png) [@marcprux](https://forums.swift.org/u/marcprux)\
**Post date:** [October 29, 2025, 7:48pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/14 "2025-10-29T19:48:36Z")

</div>

> [@purpln](#):
>
> I've also faced the need for an even lower NDK version (21)

I'm assuming you mean API level 21, not NDK version.

> [@purpln](#):
>
> If an `@available` check is coming soon, why not simply mark all the relevant APIs - for example, `Process` from Foundation and `Subprocess`

Yes, that feature will enable us to do that (should we decide to target the lower API levels). But we'd need to build using a higher NDK version (28+, I think).

I'll see what happens when I try building for API 21. Anyone have an even _lower_ Android API they need to target?

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [October 29, 2025, 7:53pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/15 "2025-10-29T19:53:20Z")

</div>

I don't think API 21 is worth it, as [they plan to drop it in the coming year, making 23 the lowest available in the NDK](https://github.com/android/ndk/issues/2188).

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [October 29, 2025, 7:57pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/16 "2025-10-29T19:57:24Z")

</div>

> [@marcprux](#):
>
> I'll see what happens when I try building for API 21. Anyone have an even _lower_ Android API they need to target?

> [@Finagolfin](#):
>
> I don't think API 21 is worth it, as [they plan to drop it in the coming year, making 23 the lowest available in the NDK](https://github.com/android/ndk/issues/2188).

My two cents: if Google and/or the OHA only supports API level _n_ and up, we should follow suit.

---

<div class="post-metadata">

**Author:** ![purpln](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/purpln/32/42536_2.png) [@purpln](https://forums.swift.org/u/purpln)\
**Post date:** [October 29, 2025, 8:14pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/17 "2025-10-29T20:14:38Z")

</div>

I agree that for the vast majority, API 23 is more than sufficient. I actually meant version 23 when I wrote " the lower, the better" - sorry for not specifying. I only mentioned version 21 remembering personal experience.

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [November 5, 2025, 9:28pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/18 "2025-11-05T21:28:01Z")

</div>

Just got off the latest Android workgroup call, where we went over all this again in detail.

I think we can go ahead and push this down to API 24 in the coming month, which really won't require much. The main reason we chose API 28 so far is because the Process APIs in Foundation depend on `posix_spawn()`, which were only added to Bionic in API 28. There was some concern today that the existing polyfills in Foundation may not work as well, but since [the current `dlsym()`-based approach only loads those polyfills at runtime](https://github.com/swiftlang/swift-corelibs-foundation/blob/ec675206c8cd939fbd4783421ea07954dcb5e175/Sources/CoreFoundation/CFPlatform.c#L2212) on devices at API level 27 and earlier that don't have `posix_spawn()` APIs in Bionic, that shouldn't be a problem for devices running API 28 and above, ie we're not statically compiling in the polyfills at compile-time.

If those who want to push this SDK down to earlier than API 28, such as @madsodgaard and @etcwilde so far, are willing to add polyfills for [the remaining three APIs that I mentioned earlier](https://github.com/swiftlang/swift-corelibs-foundation/pull/2928), and any other small changes that are needed, I'm fairly certain we could get this SDK down to API 24 with a couple days' work.

That then leaves API 23, which is a bigger question, largely because of the way `FILE` changed with API 24 in Bionic and how Swift deals with such pointer types. Starting with API 24, [it is an opaque struct in Bionic](https://android.googlesource.com/platform/bionic/+/02ce401d1e2b31586c94c8b6999364bbbce27388/libc/include/stdio.h#59), so `FILE*` is an `OpaquePointer`, but [earlier](https://android.googlesource.com/platform/bionic/+/02ce401d1e2b31586c94c8b6999364bbbce27388/libc/include/stdio.h#49), it [did have a definition](https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/bits/struct_file.h#36), so while the difference may not matter in C and C++, Swift imports them with different types.

Mads and others don't see a way to use [API notes](https://clang.llvm.org/docs/APINotes.html) to automatically change all `FILE*` in code targeting API 23 to `OpaquePointer`, so the only way they see is to add API notes for _every single_ Bionic API that invokes a `FILE*` to change its type, which seems unworkable to me.

Perhaps someone who knows these C typing issues better can chime in on whether that is our only option. The other issues with API 23 appear minor.

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [November 5, 2025, 9:38pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/19 "2025-11-05T21:38:48Z")

</div>

This might not pan out, but what if you use `swift_newtype(struct)` for the `FILE` typedef? I thiiink there’s an apinote form of that. Then you have a consistent wrapper type even though it’ll have a different raw value on 23 vs 24.

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [November 5, 2025, 10:00pm UTC](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874/20 "2025-11-05T22:00:07Z")

</div>

> [@Finagolfin](#):
>
> Mads and others don't see a way to use [API notes](https://clang.llvm.org/docs/APINotes.html) to automatically change all `FILE*` in code targeting API 23 to `OpaquePointer`, so the only way they see is to add API notes for _every single_ Bionic API that invokes a `FILE*` to change its type, which seems unworkable to me.

Swift Testing has this in a header:

```c++
typedef FILE *SWTFilePointer;

```

And then we just refer to `SWTFilePointer` instead. For something public-facing, we could make sure the `Android` module overlay has something equivalent, perhaps? (Actually, frankly, we probably should have something equivalent in _all_ the C stdlib modules, since the `FILE *` type is imported various different ways across them. But that's beyond the scope of your work.)

[Next page](https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874.md?page=2)
