The Swift SDKs for Cross-Compilation introduced in SE-0387 specifies a swift-sdk.json
configuration file that enumerates the various supported triples and their properties like sdkRootPath
, swiftResourcesPath
, includeSearchPaths
, etc. All these properties except sdkRootPath
have heretofore been optional.
For the Swift Android SDK, we want to have the sdkRootPath
be configurable by the end-user because it is going to need to point to an external NDK sysroot. This is both so we don't need to ship the NDK sysroot subset along with the Swift Android SDK, and also because a user may want to be able to control the version of the NDK that is associated with the cross-compilation process. This will be accomplished by running the swift sdk configure
command to specify the intended sdkRootPath
after the SDK has been installed.
As a concrete example, after running:
swift sdk configure swift-6.2-RELEASE-android-0.1 --sdk-root-path /opt/homebrew/share/android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/sysroot
…the ~/Library/org.swift.swiftpm/swift-sdks/swift-6.2-RELEASE-android-0.1.artifactbundle/swift-android/swift-sdk.json
would wind up looking like this:
{
"schemaVersion": "4.0",
"targetTriples": {
"aarch64-unknown-linux-android28": {
"sdkRootPath": "/opt/homebrew/share/android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/sysroot",
"swiftResourcesPath": "swift-resources/usr/lib/swift-aarch64",
"swiftStaticResourcesPath": "swift-resources/usr/lib/swift_static-aarch64",
"toolsetPaths": [ "swift-toolset.json" ]
},
"x86_64-unknown-linux-android28": {
"sdkRootPath": "/opt/homebrew/share/android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/sysroot",
"swiftResourcesPath": "swift-resources/usr/lib/swift-x86_64",
"swiftStaticResourcesPath": "swift-resources/usr/lib/swift_static-x86_64",
"toolsetPaths": [ "swift-toolset.json" ]
},
"armv7-unknown-linux-android28": {
"sdkRootPath": "/opt/homebrew/share/android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/sysroot",
"swiftResourcesPath": "swift-resources/usr/lib/swift-armv7",
"swiftStaticResourcesPath": "swift-resources/usr/lib/swift_static-armv7",
"toolsetPaths": [ "swift-toolset.json" ]
}
}
Support for this has been added in Allow omitting the target triple for `swift sdk configure` by marcprux · Pull Request #8856 · swiftlang/swift-package-manager · GitHub. The only weird part is that since the sdkRootPath
is non-optional, a freshly-installed and unconfigured Swift Android SDK still needs some placeholder for the sdkRootPath
property. We would like to make this property optional so that it is clear that it needs to be manually configured after the SDK has been installed.
Does anyone see any issue with the sdkRootPath
being optional? This would require updating the mention of the optionality of the property at proposals/0387-cross-compilation-destinations.md
(which I've filed at Update sdkRootPath to be optional in swift-sdk.json by marcprux · Pull Request #2888 · swiftlang/swift-evolution · GitHub). I would be surprised if this directly affects any existing projects, since I don't think the swift sdk configure
command is used by anyone.