Archiving SPM Projects
An archive is a packaged, distributable bundle of a project’s compiled output — native libraries, executables, and resources — ready to be shipped or embedded into another project, rather than just compiled and checked for errors.
The archive command builds an SPM project and packages the result into such an artifact. Unlike build, it can target multiple platforms in a single invocation.
scd archive --platform <platform> --configuration Releasearchive accepts the same SPM Build Options as build, plus options specific to archiving — see scd archive for the full list.
Archive Types
Section titled “Archive Types”Three archive types are available, selected with --type.
File Tree
Section titled “File Tree”The default archive type. Produces a directory with native libraries organized by platform under lib/<platform>/ — for Android, this uses the ABI name (e.g. lib/arm64-v8a/), following the standard jniLibs layout, so the output can be dropped directly into an Android project.
scd archive --platform android-arm64-v8a --output ./ArchiveSelected with --type android-aar, this archive type packages the project as an Android library archive (.aar), ready to be added as a dependency to an Android project. The output is named <AppName>-<debug|release>.aar.
Building an AAR requires an AndroidManifest.xml in the project root. If it doesn’t exist, pass --generate-android-manifest to have scd generate one automatically.
scd archive --platform android-arm64-v8a --type android-aar --generate-android-manifestAndroid Test APK
Section titled “Android Test APK”Selected with --type android-test-apk, this archive type packages the project’s XCTest suite as a standalone, installable APK that runs the tests on launch — useful for running tests outside of the test command, for example on a CI device farm. scd generates a self-contained Android test project automatically, so no AndroidManifest.xml is required. The output is named <AppName>Test-<debug|release>.apk.
scd archive --platform android-arm64-v8a --type android-test-apkBoth the AAR and Android Test APK archive types build the project’s tests automatically, regardless of whether --build-tests is passed.
Multi-Architecture Archives
Section titled “Multi-Architecture Archives”archive accepts multiple --platform values in a single invocation, combining all of them into one artifact:
scd archive --platform android-arm64-v8a --platform android-armeabi-v7a --type android-aarPackage Metadata
Section titled “Package Metadata”--package-id, --package-version, and --package-string-version set the package identifier and version used for the archive and, when generated, the AndroidManifest.xml:
scd archive --platform android-arm64-v8a --type android-aar \ --package-id com.example.myapp --package-version 3 --package-string-version 1.2.0Selecting Products
Section titled “Selecting Products”By default, archive includes all products in the project. To archive only specific products, pass --product one or more times:
scd archive --platform android-arm64-v8a --product MyLibraryOutput Path
Section titled “Output Path”Use -o/--output to set the output directory or file path. If not specified, the archive is created in the current directory.