Skip to content

Add Android Bionic support so SwiftNetwork builds on the Android SDK. - #219

Open
Cartisim wants to merge 3 commits into
apple:mainfrom
needletails:main
Open

Cartisim wants to merge 3 commits into
apple:mainfrom
needletails:main

Conversation

@Cartisim

@Cartisim Cartisim commented Oct 6, 2026

Copy link
Copy Markdown

Motivation

os(Android) is not os(Linux). Swift on Android uses Bionic (import Android), so the existing Glibc / Musl Linux path does not compile as-is.

This change teaches SwiftNetwork that platform with the smallest possible delta: reuse the Linux system layer, import Android where Glibc was required, and paper over the few Bionic ABI differences the compiler actually hits.

Darwin behavior is unchanged.

Modifications

  • Enable Logging and SwiftNetworkLinuxShim for .android in Package.swift.
  • Compile the Linux system / netlink path as os(Linux) || os(Android).
  • Import Android in sources that already imported Glibc.
  • Gate Darwin-only files with canImport(Darwin) so they are not built for Android.
  • Wrap Bionic’s variadic ioctl as SwiftNetworkLinuxShim_ioctl (unavailable from Swift).
  • Match Bionic nullability for recvmsg / sendmsg / if_nametoindex, and use in6_addr.in6_u.u6_addr32 for IPv6.
  • Extend the Linux-only #ifs that fail to compile on Android (Logger.notice, errSecSuccess, QUIC session-state callbacks, CryptoKitMetaError).

No new Android-specific networking implementation is added.

Testing

  • Built SwiftNetwork for aarch64-unknown-linux-android24.
  • Ran the Android test suite. Existing Darwin / Linux interface assumptions (lo0 vs lo, MTU, interface type) still fail on Android and are not addressed here.
  • Please also confirm Darwin and Linux still build.

…on matches the kernel, and configure QUIC keepalive on an already-held event context.
Tie frame spans to their owning FrameArray lifetime and replace the deprecated deque reallocation API with setCapacity.
@rpaulo rpaulo added the ⚠️ semver/major Breaks existing public API. label Oct 6, 2026
@tfpauly

tfpauly commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Note the overlap with #222

@rpaulo

rpaulo commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@Cartisim could you please let us know if there's anything in this PR that is not in PR 222?

@finagolfin

Copy link
Copy Markdown

@Cartisim, this is strange, that we both submitted this within hours of each other. Since you say you didn't get all the tests passing, while I did in my pull linked above, do you mind if I get mine in first, then you can rebase off that and propose any differences that remain here? Most of our pulls is just adding Android imports, so won't be much left once that's in.

How did you build and test this exactly, natively on Android in the Termux app?

@rpaulo rpaulo added 🔨 semver/patch No public API change. and removed ⚠️ semver/major Breaks existing public API. labels Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants