Help with Android Swift SDK

I have been interested in testing the Swift Android SDK, but I have struggles just building the example from the “Getting Started with the Swift SDK for Android“. Is there something I am missing?

macOS 26.1 (25B77)

(base) user@10-20-37-127 ~ % swift --version                         

Apple Swift version 6.3-dev (LLVM 3a427639f2a06cf, Swift 5417f00a58578de)
Target: arm64-apple-macosx26.0
Build config: +assertions

(base) user@10-20-37-127 ~ % cd /tmp    
(base) user@10-20-37-127 /tmp % mkdir hello
(base) user@10-20-37-127 /tmp % cd hello                   
(base) user@10-20-37-127 hello % swiftly run swift package init --type executable
Creating executable package: hello
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello/hello.swift
Creating Tests/
Creating Tests/helloTests/
Creating Tests/helloTests/helloTests.swift
(base) user@10-20-37-127 hello % swiftly run swift build
Building for debugging...
error: link command failed with exit code 1 (use -v to see invocation)
ld: unknown option: -no_warn_duplicate_libraries
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[6/8] Linking hello


Using invocation throws the following:

(base) user@10-20-37-127 hello % swiftly run swift build -v
warning: ‘hello’: /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /private/tmp/hello/Package.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -I /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/pm/ManifestAPI -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -vfsoverlay /var/folders/69/6gbdnhgx5y3_xnc99kqgpnd00000gp/T/TemporaryDirectory.HgAbYS/vfs.yaml -no-color-diagnostics -Xcc -fno-color-diagnostics -swift-version 6 -package-description-version 6.3.0 -empty-abi-descriptor -plugin-path /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/host/plugins/testing -no-auto-bridging-header-chaining -module-name main -in-process-plugin-server-path /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 26.0 -target-sdk-name macosx26.0 -external-plugin-path ‘/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server’ -external-plugin-path ‘/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server’ -o /var/folders/69/6gbdnhgx5y3_xnc99kqgpnd00000gp/T/TemporaryDirectory.ML8bw5/Package-1.o
/Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/bin/clang /var/folders/69/6gbdnhgx5y3_xnc99kqgpnd00000gp/T/TemporaryDirectory.ML8bw5/Package-1.o -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks –sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk –target=arm64-apple-macosx14.0 -L /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/swift -rpath /usr/lib/swift -L /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/pm/ManifestAPI -L /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -lPackageDescription -Xlinker -rpath -Xlinker /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/pm/ManifestAPI -o /var/folders/69/6gbdnhgx5y3_xnc99kqgpnd00000gp/T/TemporaryDirectory.0MmnXt/hello-manifest
Apple Swift version 6.3-dev (LLVM 3a427639f2a06cf, Swift 5417f00a58578de)
Target: arm64-apple-macosx14.0
Planning build
Building for debugging…
Write auxiliary file /private/tmp/hello/.build/arm64-apple-macosx/debug/swift-version–345448C0BFDF444B.txt
/Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/bin/swiftc -module-name hello -emit-dependencies -emit-module -emit-module-path /private/tmp/hello/.build/arm64-apple-macosx/debug/Modules/hello.swiftmodule -output-file-map /private/tmp/hello/.build/arm64-apple-macosx/debug/hello.build/output-file-map.json -incremental -c @/private/tmp/hello/.build/arm64-apple-macosx/debug/hello.build/sources -I /private/tmp/hello/.build/arm64-apple-macosx/debug/Modules -target arm64-apple-macosx10.13 -v -incremental -enable-batch-mode -serialize-diagnostics -index-store-path /private/tmp/hello/.build/arm64-apple-macosx/debug/index/store -Onone -enable-testing -j8 -DSWIFT_PACKAGE -DDEBUG -DSWIFT_MODULE_RESOURCE_BUNDLE_UNAVAILABLE -module-cache-path /private/tmp/hello/.build/arm64-apple-macosx/debug/ModuleCache -parseable-output -Xfrontend -entry-point-function-name -Xfrontend hello_main -parse-as-library -color-diagnostics -swift-version 6 -I /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing -L /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing -plugin-path /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/host/plugins/testing -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -g -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -Xcc -fPIC -Xcc -g -package-name hello
Apple Swift version 6.3-dev (LLVM 3a427639f2a06cf, Swift 5417f00a58578de)
Target: arm64-apple-macosx10.13
/Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/bin/swiftc -v -L /private/tmp/hello/.build/arm64-apple-macosx/debug -o /private/tmp/hello/.build/arm64-apple-macosx/debug/hello -module-name hello -Xlinker -no_warn_duplicate_libraries -emit-executable -Xlinker -alias -Xlinker _hello_main -Xlinker _main -Xlinker -rpath -Xlinker @loader_path @/private/tmp/hello/.build/arm64-apple-macosx/debug/hello.product/Objects.LinkFileList -Xlinker -rpath -Xlinker /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift-5.5/macosx -Xlinker -rpath -Xlinker /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift-6.2/macosx -target arm64-apple-macosx10.13 -Xlinker -add_ast_path -Xlinker /private/tmp/hello/.build/arm64-apple-macosx/debug/Modules/hello.swiftmodule -I /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing -L /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing -plugin-path /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/host/plugins/testing -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -g
Apple Swift version 6.3-dev (LLVM 3a427639f2a06cf, Swift 5417f00a58578de)
Target: arm64-apple-macosx10.13
/Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/bin/clang /private/tmp/hello/.build/arm64-apple-macosx/debug/hello.build/hello.swift.o -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks –sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk –target=arm64-apple-macosx10.13 -force_load /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/libswiftCompatibilityConcurrency.a -force_load /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/libswiftCompatibility56.a /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/libswiftCompatibilityPacks.a -L /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/swift -rpath /usr/lib/swift -L /private/tmp/hello/.build/arm64-apple-macosx/debug -L /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift/macosx/testing -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -Xlinker -no_warn_duplicate_libraries -Xlinker -alias -Xlinker _hello_main -Xlinker _main -Xlinker -rpath -Xlinker @loader_path -Xlinker -rpath -Xlinker /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift-5.5/macosx -Xlinker -rpath -Xlinker /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a.xctoolchain/usr/lib/swift-6.2/macosx -Xlinker -add_ast_path -Xlinker /private/tmp/hello/.build/arm64-apple-macosx/debug/Modules/hello.swiftmodule -o /private/tmp/hello/.build/arm64-apple-macosx/debug/hello
error: link command failed with exit code 1 (use -v to see invocation)
ld: unknown option: -no_warn_duplicate_libraries
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Your swiftly build is not specifying the --swift-sdk like the instructions specify.

Here's what it looks like on my macOS machine:

marc@zap /tmp % cd android-demo 

marc@zap android-demo % swiftly use main-snapshot-2025-10-16
The global default toolchain has been set to `main-snapshot-2025-10-16` (was 6.2.0)

marc@zap android-demo % swiftly run swift package init --type executable
Creating executable package: android-demo
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/android-demo/android_demo.swift

marc@zap android-demo % swiftly run swift build --swift-sdk x86_64-unknown-linux-android28 --static-swift-stdlib
[1/1] Planning build
Building for debugging...
[7/7] Linking android-demo
Build complete! (2.29s)
3 Likes

Thanks you so much,

Since I was following the try building part before continuing I did not wanted to be out of that step before continuing the tutorial.

Snippet from “Getting Started with the Swift SDK for Android“

Try it out by building and running locally for the host machine:

swiftly run swift build
Building for debugging...
[8/8] Applying hello
Build complete! (15.29s)

.build/debug/hello
Hello, world!

I see. It is an odd error. What version of Xcode do you have installed?

Also, please try the subsequent build command (with --swift-sdk …) and let us know if that works. The local build command isn't a pre-requisite to any subsequent step, it is just there to show that the program can run locally.

1 Like

Xcode Version 26.0.1 (17A400)

It works with the full build command

swiftly run swift build --swift-sdk x86_64-unknown-linux-android28 --static-swift-stdlib

Trying to run it locally (without specifying the --swift-sdk), leads to the same error shown in the post

(base) user@10-20-37-127 hello % swiftly run swift build
Building for debugging...
error: link command failed with exit code 1 (use -v to see invocation)
ld: unknown option: -no_warn_duplicate_libraries
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[6/8] Linking hello

Thanks again.