Skip to main content

asset-guard

A Python (3.12+) CLI that keeps Xcode asset catalogs (.xcassets) lean. It finds unused, duplicate, and broken image assets, and can remove unused image sets before you build. It is designed to run in GitHub Actions, Jenkins, or any other CI.


Features

  • Unused assets: finds image sets that nothing references. Detection is conservative, so clean does not delete images that are in use. It checks:
    • every string literal in Swift and Objective-C (UIImage(named:), Image("…"), enums, constants, SwiftGen, R.swift),
    • dynamic names ("icon_\(i)", @"icon_%d"),
    • Xcode 15+ generated symbols (Image(.logo), UIImage.logo, ImageResource.logo),
    • storyboard/XIB attributes and plist strings.
  • Remove unused assets: asset-guard clean shows what it would delete; --apply deletes whole .imageset folders. It refuses to run when the catalogs have uncommitted git changes, so every deletion can be reverted.
  • Duplicate images: finds byte-identical files across image sets and reports the wasted space. Duplicates are reported, never auto-deleted.
  • Broken image sets: invalid or missing Contents.json, missing files, missing @2x/@3x, vectors with an explicit scale, and duplicate asset names.
  • Built for CI: --fail-on unused,duplicates,broken, --report-json, --summary-file (GitHub step summary), meaningful exit codes, a GitHub Action, and a Jenkins example. See docs/ci.md.
  • Multiple catalogs: discovers every .xcassets in the project (app, widgets, local packages) and skips Pods, .build, DerivedData, and Carthage.

Quick start

# Run directly without installing (requires uv)
uvx asset-guard audit /path/to/MyApp

# Or install globally
uv tool install asset-guard   # or: pip install asset-guard

# Dry run: list unused image sets that would be removed
asset-guard clean /path/to/MyApp

# Delete them (requires committed, clean catalogs, or pass --force)
asset-guard clean /path/to/MyApp --apply

# CI gate: exit 1 if unused or duplicate images exist, and save a JSON report
asset-guard audit . --fail-on unused,duplicates --report-json asset-guard.json

Try it on the bundled sample project: uv run asset-guard audit examples/SampleApp.

Configuration (optional)

.asset-guard.toml in the project root:

ignore = ["seasonal_*"]        # asset-name globs that are never reported or removed
exclude-dirs = ["Generated"]   # extra source dirs to skip
expected-scales = ["2x", "3x"] # required bitmap scales
scan-interface-builder = true

CI

# GitHub Actions
- uses: nguyen-ta-cuong/asset-guard@v0.1.0
  with:
    command: clean
    apply: "true"

See docs/ci.md for PR checks, release builds, the Jenkins pipeline, exit codes, and the git safety check.


Development

Requirements: Python >= 3.12 and uv.

git clone https://github.com/nguyen-ta-cuong/asset-guard.git
cd asset-guard
make dev      # create .venv with pytest, ruff, ty
make lint     # ruff format check + ruff check + ty
make test     # pytest with coverage gate
uv run asset-guard --help

See AGENTS.md for the module layout, conventions, and safety rules.


Roadmap

  1. Asset-level duplicate grouping & local-only dedupe — Group duplicates where all scales of set A match set B, with an opt-in local command that safely rewrites references.
  2. Richer CI report formats — SARIF (for GitHub Code Scanning annotations on PRs) and JUnit XML (for Jenkins test reports), wired through reporting.py and _write_outputs.
  3. Broader catalog coverage — Extend catalog.py to .colorset and .symbolset.

License

MIT — see LICENSE.

Metadata

Release files for asset-guard 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asset-guard 0.1.0
File Size Uploaded Provenance Actions
asset_guard-0.1.0.tar.gz 21.6 kB Without provenance Details for asset_guard-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for asset-guard 0.1.0
File Interpreter ABI Platform Actions
asset_guard-0.1.0-py3-none-any.whl Python 3 none any Details for asset_guard-0.1.0-py3-none-any.whl

Total release size: 46.5 kB

Release files / asset_guard-0.1.0.tar.gz

Download URL asset_guard-0.1.0.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e9b7ac1c7d16c5dc5979a3e7a8c787bd496cc47a1bedc1579fd4cdc12d56246e
BLAKE2b-256 checksum
How to use checksums
99e5a4089a92b25531cb582b4290b4a793caaef86c2a0d6fac032d3efa01de14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / asset_guard-0.1.0-py3-none-any.whl

Download URL asset_guard-0.1.0-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33fcb0a885e13ab9bed3e1f6832048a9ea0436c952ebfce3f53a54cfb648c114
BLAKE2b-256 checksum
How to use checksums
d9f2b9cb82493d00dd3dc2c2c6fc419e2971e1feec1a25a2db18ac06a656e6f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for asset-guard 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page