Build Android Swift packages with the toolchain's default build system - #119
Merged
marcprux merged 3 commits intoSep 26, 2026
Merged
Conversation
The --build-system native pin from skiptools#106 was a stopgap for swiftlang/swift-build#1363, which is fixed; swiftbuild now writes per-architecture product folders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
piercifani
marked this pull request as ready for review
September 23, 2026 19:08
This was referenced Sep 24, 2026
marcprux
requested changes
Sep 25, 2026
loadPeerLibrary only looked in the native build system's <triple>/debug folder, so Robolectric tests could not find the host library once swift build defaulted to swiftbuild, which writes to out/Products/<configuration>. Fall back to that folder when the native path does not exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The nightly toolchain's swiftbuild reads -module-cache-path from the
swiftc flags and took the following -Xfrontend as its value ("Cannot
recursively create directory at non-absolute path: -Xfrontend"). The
driver option is equivalent under the native build system.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
piercifani
force-pushed
the
android-build-default-build-system
branch
from
September 25, 2026 21:59
46e8993 to
ed50343
Compare
marcprux
approved these changes
Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#106 pinned the generated
buildAndroidSwiftPackagetask to--build-system nativeas a stopgap while swiftlang/swift-build#1363 was open: swiftbuild's build output folder no longer included the target triple, which multi-architecture exports (--arch aarch64 --arch armv7) rely on to collect each architecture's libraries.That issue was closed on 2026-07-13, and Swift 6.4's swiftbuild writes per-architecture product folders (
out/Products/Release-android-aarch64,out/Products/Release-android-armv7). Meanwhile every 6.4 build prints the'--build-system native' has been deprecated and will be removedwarning. Once SwiftPM dropsnative, the generated task stops building.This PR makes three changes:
skip android builduses the toolchain's default engine. Toolchains before 6.4 default tonative, so nothing changes for them. On 6.4 and later, the Android build moves to swiftbuild.loadPeerLibraryswiftbuild's product folder. For Robolectric it only looked in the native engine's.build/<lib>/swift/<triple>/debug/, but swiftbuild writes the host library to.build/<lib>/swift/out/Products/Debugon macOS andDebug-linux-<arch>on Linux. It now falls back to that folder when the native path doesn't exist. This already breaks onmainfor anyone whose hostswift buildruns on swiftbuild: onmain,swift testin this repo with Xcode 27 / Swift 6.4 fails every Robolectric test witherror: missing library: …/<triple>/debug/lib<Module>.dylib. The first CI run of this PR hit the same failure on theubuntu-24.04, nightly-mainjob.-Xswiftc -module-cache-path -Xswiftc <path>, instead of-Xfrontendpairs. The nightly toolchain's swiftbuild reads-module-cache-pathfrom the swiftc flags, took the following-Xfrontendas the directory, and failed withCannot recursively create directory at non-absolute path: -Xfrontend. Under the native build system the two forms are equivalent: the module cache is still written tobuild/swift/module-cache/<module>.Verified
A 16-module bridged package (~2,400 Swift files), Swift 6.4.0 (Xcode 27) with the 6.4.0 Android SDK, skip 1.9.11, skip-bridge 0.17.3 + this change:
skip export --release --arch aarch64 --arch armv7: succeeds. All 16 AARs are produced, and each architecture'sjni/folder holds the same 28 libraries.skip export --debug --arch aarch64driven by the consuming app's Gradle build, then:app:assembleDebug: succeeds.--build-system native, same checkout: the same 16 AARs with identical per-ABI library lists (28 each). Total native-library size is within 0.04% (arm64-v8a 439.0 → 439.2 MB, armeabi-v7a 420.0 → 419.9 MB), and the cold export went from 823 s to 808 s.swift testin this repo, Xcode 27 / Swift 6.4 on macOS:mainfails every Robolectric test withmissing library. With this PR, all Robolectric suites pass, loadingout/Products/Debug/lib<Module>.dylib.One unrelated thing we noticed:
jni-libs/<abi>is shared between debug and release, so a release export after a debug export can carry debug-only libraries such aslibswiftSwiftOnoneSupport.sointo the release AAR. Clearing the folder avoids it. This happens independently of the build engine.🤖 Generated with Claude Code