nsassetscli is a macOS Swift CLI that connects Xcode snapshot test output with NSAssets macOS app.
It helps you set up a repository for NSAssets-driven snapshot workflows, inject managed post-test actions into the right .xcscheme files, parse fresh xcresult data into structured JSON artifacts, and notify the NSAssets macOS app when new results are available.
The CLI currently provides three main workflows:
initbootstraps a repository by creating.nsassets.json, preparing artifact folders, and optionally updating.gitignore.schemes sync-post-actionsrewrites selected test schemes so they run the managednsassetscli xcresult parsehook after tests finish.xcresult parseresolves the latest matchingxcresult, exports failure details and attachments, and writes structured output intonsassets-artifacts/.
Run the setup wizard once from your project root to collect the iOS version, simulator model, Xcode version, project file, local packages path, and the snapshot test schemes you want to manage.
nsassetscli initThis creates .nsassets.json, prepares nsassets-artifacts/logs, and can append nsassets-artifacts/ to .gitignore.
If new snapshot schemes are added, moved, or recreated, run the sync command from the repository root to re-inject the managed post-action into the selected schemes stored in .nsassets.json.
nsassetscli schemes sync-post-actionsThe managed scheme hook calls this automatically after tests, but you can also run it manually when debugging.
nsassetscli xcresult parse \
--scheme Snapshots \
--project-name MyApp \
--workspace-path "/Users/me/Projects/MyApp/MyApp.xcworkspace"This writes a JSON summary to nsassets-artifacts/xcresults/Snapshots.json, exports failure attachments into a per-test folder, and attempts to notify NSAssets macOS app.
brew tap michaelversus/aperturecli https://github.com/michaelversus/aperturecli.git
brew install nsassetsclimake install prefix=/usr/localIf the Xcode post-action does not behave as expected, check the generated logs in:
nsassets-artifacts/logs/<SchemeName>.logIf the log shows a command-not-found error for nsassetscli, verify that Homebrew installed the binary at the expected path:
/opt/homebrew/bin/nsassetscli --versionIf that command fails, reinstall or relink the formula, or edit the test post-actions for your scheme manually before rerunning your tests.
nsassetsclidefaults to theinitworkflow.--versionprints the CLI version.--helpprints command usage.
- Launches the interactive setup wizard.
- Requires Xcode to be closed while the setup is running.
- Scans project and package schemes to discover candidate snapshot test schemes.
- Writes
.nsassets.jsonin the current repository root. - Creates
nsassets-artifacts/logs. - Optionally updates
.gitignore.
- Loads
.nsassets.jsonfrom the current repository root. - Finds the selected snapshot schemes again.
- Injects or refreshes the managed NSAssets shell-script post action in those
.xcschemefiles.
--schemeis the scheme name used to match the latestxcresult.--project-nameis the Xcode project name without the.xcodeprojextension.--workspace-pathis optional and helps the CLI derive the repository root for output paths and NSAssets Studio notifications.
nsassetscliBecause init is the default subcommand, running the root command without arguments starts the same workflow as nsassetscli init.
Close Xcode before running init so the setup can safely inspect and update your scheme configuration.
cd /Users/me/Projects/MyApp
nsassetscli schemes sync-post-actionsSample output:
Matched schemes: 2
Updated scheme files: 2
Updated scheme file paths:
/Users/me/Projects/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/Snapshots.xcscheme
/Users/me/Projects/MyApp/Packages/FeatureUI/xcshareddata/xcschemes/FeatureSnapshots.xcscheme
nsassetscli xcresult parse \
--scheme Snapshots \
--project-name MyApp \
--workspace-path "/Users/me/Projects/MyApp/MyApp.xcworkspace"Sample output:
/Users/me/Projects/MyApp/nsassets-artifacts/xcresults/Snapshots.json
init writes a .nsassets.json file in the repository root. It stores the values needed to rediscover schemes and keep post-actions in sync.
Example:
{
"iosVersion": "18.2",
"projectFileName": "MyApp.xcodeproj",
"repoRoot": "/Users/me/Projects/MyApp",
"simulatorModel": "iPhone 16 Pro",
"snapshotTestSchemes": [
"Snapshots",
"FeatureSnapshots"
],
"spmPackagesContainerPath": "Packages",
"xcodeVersion": "16.2"
}nsassetscli xcresult parse writes output under nsassets-artifacts/:
nsassets-artifacts/logs/<Scheme>.logstores the managed scheme post-action log.nsassets-artifacts/xcresults/<Scheme>.jsonstores the structured parsed summary for NSAssets Studio.nsassets-artifacts/xcresults/<Scheme>/attachments/...stores exported attachments grouped by failed test identifier.
- The wizard prompts for repository-specific Xcode and simulator details.
- It resolves the project file and optional local packages path.
- It scans
.xcschemefiles from the app project and package container to discover snapshot test schemes. - It stores the selected scheme names in
.nsassets.jsonand optionally updates.gitignore.
- The sync command reloads
.nsassets.json. - It locates the selected schemes again across the project and package container.
- It injects a managed shell-script post action into each matching scheme.
- That post action runs
nsassetscli xcresult parsein the background and appends logs tonsassets-artifacts/logs/<Scheme>.log.
- The parser resolves the latest matching
xcresultin DerivedData for the given scheme and project name. - It reads the summary, failed tests, per-test details, activity attachments, and exported attachment manifests through
xcresulttool. - It writes a pretty-printed JSON artifact into
nsassets-artifacts/xcresults/. - It notifies NSAssets macOS app through a distributed notification. If the app is not running, the CLI prompts in interactive terminals and auto-launches in non-interactive environments.
The package uses Swift Testing with focused unit tests for setup prompting, config loading and writing, scheme synchronization, post-action generation, xcresult parsing, derived-data resolution, and app-bridge behavior.
Run the test suite with:
swift test