Auto-detect installed Android Swift SDK artifactbundle - #50
Open
otondin wants to merge 1 commit into
Open
Conversation
…ssing its name
All four Swift/Android build scripts (swift-android.gradle.kts and the
copy-pasted Groovy build.gradle files in hello-cpp-swift/swift-lib,
hello-swift-java/hashing-lib, and swift-java-weather-app/weather-lib)
guessed the installed Android Swift SDK artifactbundle directory name as
"swift-${swiftVersion}-RELEASE_android.artifactbundle". In practice `swift
sdk install` names the bundle after the exact resolved patch version (e.g.
requesting "6.3" installs "swift-6.3.3-RELEASE_android.artifactbundle"),
so the guessed path silently didn't exist for most users.
This caused two distinct failures depending on where the wrong path was
used:
- swiftBuild*/-resource-dir: `swift build` failed outright with "unable
to load standard library for target ..." (hello-swift-raw-jni-callback).
- copyJniLibs' Copy task: silently dropped every Swift runtime .so
(libswiftCore, libswiftSwiftOnoneSupport, libc++_shared, ...) from the
from(...) sources instead of failing, since Gradle's Copy task doesn't
error on missing sources. The app built and installed fine but crashed
on the first Swift call with dlopen failures (hello-swift-java).
Both are reported in swiftlang#42.
Replace the guess with resolveAndroidSdkVersion(), which scans the Swift
SDK directory for installed "*android*.artifactbundle" folders instead of
assuming a naming scheme: a single match is used as-is (covers the common
case of one SDK installed, any naming convention including snapshots), and
among multiple matches the one starting with the configured swiftVersion
is preferred, falling back to the most recently installed. An explicit
SWIFT_ANDROID_SDK_VERSION override, or a directory with no matches, still
behaves as before.
Verified by rebuilding native-activity and hello-swift-java-hashing-app
from a clean environment with SWIFT_ANDROID_SDK_VERSION unset: both now
correctly locate swift-6.3.3-RELEASE_android.artifactbundle and the
hashing app's jniLibs directory includes the previously-missing runtime
libraries.
Fixes swiftlang#42
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hhgbd7ipopFKHSKWWnC4UH
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.
Fixes #42