Skip to content

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.

Terminal window
scd archive --platform <platform> --configuration Release

archive accepts the same SPM Build Options as build, plus options specific to archiving — see scd archive for the full list.

Three archive types are available, selected with --type.

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.

Terminal window
scd archive --platform android-arm64-v8a --output ./Archive

Selected 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.

Terminal window
scd archive --platform android-arm64-v8a --type android-aar --generate-android-manifest

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.

Terminal window
scd archive --platform android-arm64-v8a --type android-test-apk

Both the AAR and Android Test APK archive types build the project’s tests automatically, regardless of whether --build-tests is passed.

archive accepts multiple --platform values in a single invocation, combining all of them into one artifact:

Terminal window
scd archive --platform android-arm64-v8a --platform android-armeabi-v7a --type android-aar

--package-id, --package-version, and --package-string-version set the package identifier and version used for the archive and, when generated, the AndroidManifest.xml:

Terminal window
scd archive --platform android-arm64-v8a --type android-aar \
--package-id com.example.myapp --package-version 3 --package-string-version 1.2.0

By default, archive includes all products in the project. To archive only specific products, pass --product one or more times:

Terminal window
scd archive --platform android-arm64-v8a --product MyLibrary

Use -o/--output to set the output directory or file path. If not specified, the archive is created in the current directory.