👮Sanitize your Assets.xcassets files

Overview

Localize

AssetChecker

Language: Swift Platform: iOS codebeat badge License: MIT GitHub tag

AssetChecker is a tiny run script that keeps your Assets.xcassets files clean and emits warnings when something is suspicious.

AssetChecker

Because Image Assets files are not safe, if an asset is ever deleted, nothing will warn you that an image is broken in your code.

Try it!

AssetChecker is part of freshOS iOS toolset. Try it in an example App! Download Starter Project

How

By using a script running automatically, you have a safety net that makes using Asset Catalog a breeze.

What

Automatically (On build)

  • Raises Errors for Missing Assets
  • Raises warnings for Unused Assets

Installation

Installation available via Cocoapods. Add the following to your Podfile:

pod 'AssetChecker', :git => 'https://github.com/freshOS/AssetChecker.git'

Or copy the script into your project.

Add the following Run Script in XCode, this will run the script at every build. If you installed via Cocoapods, you can use the following script:

${PODS_ROOT}/AssetChecker/run --catalog ${SRCROOT}/Resource/Images.xcassets

with arguments:

--catalog Absolute path to your Asset catalog (required)
--source Absolute path to your source directory.  Defaults to $SRCROOT

If you didn't use Cocoapods, use the path of where you copied AssetChecker script:

${SRCROOT}/{PATH_TO_THE_SCRIPT}/AssetChecker.swift ${SRCROOT}/Sources ${SRCROOT}/Resources/Images.xcassets

In this example your source files are located in /Sources and your Asset catalog is in /Resources/Images.xcassets.

And configure top section of the script :

// Configure me \o/
let sourcePath = "/Sources"
let assetCatalogPath = "/Resources/Assets.xcassets"
let ignoredUnusedNames = [String]()

Run and Enjoy \o/

False positives

Sometimes you're building the asset names dynamically so there is no way for AssetChecker to find out statically by looking at the codebase.

In this case the script will emit a false positive.

You can manually declare these false positives so that they get ignored !

Set the ignoredUnusedNames variable in the script file like so:

let ignoredUnusedNames = [
    "voteEN",
    "voteES",
    "voteFR"
]

Author

Sacha Durand Saint Omer, [email protected]

Contributing

Contributions to AssetChecker are very welcomed and encouraged!

License

AssetChecker is available under the MIT license. See LICENSE for more information.

Backers

Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site :)

You might also like...
A Swift sample code to reads ISO 10303-21 exchange structures (STEP P21 files for AP242) split into multiple files using external references approach.

multipleP21ReadsSample A Swift sample code to reads ISO 10303-21 exchange structures (STEP P21 files for AP242) split into multiple files using extern

BeatboxiOS - A sample implementation for merging multiple video files and/or image files using AVFoundation

MergeVideos This is a sample implementation for merging multiple video files and

NotionDrive - A swift package that can upload files to Notion.so or download files from Notion.so

NotionDrive NotionDrive is a swift package that can upload files to Notion.so or

Highly customizable Action Sheet Controller with Assets Preview written in Swift
Highly customizable Action Sheet Controller with Assets Preview written in Swift

PPAssetsActionController Play with me ▶️ 🖐 If you want to play with me, just tap here and enjoy! 🎩 🕴 Show me 🎪 Try me 📲 The easiest way to try me

Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets.
Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets.

SwiftUI-LazyVGrid Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets. Screenshots Samples IP & Credits All those b

ColorAssetsFinder can help you find particular color assets easily by hex color code.
ColorAssetsFinder can help you find particular color assets easily by hex color code.

ColorAssetsFinder ColorAssetsFinder can help you find particular color assets easily by hex color code. Features Find particular color assets in Asset

Swift framework for working with Tiled assets in SpriteKit
Swift framework for working with Tiled assets in SpriteKit

SKTiled is a framework for integrating Tiled assets with Apple's SpriteKit, built from the ground up with Swift. This project began life as an exercis

Enables easy, convenient asynchronous asset loading in RealityKit for many different kinds of assets.

RealityKit Asset Loading Discussion This package includes classes and examples that enable easy, convenient asynchronous asset loading in RealityKit f

Highly customizable Action Sheet Controller with Assets Preview written in Swift
Highly customizable Action Sheet Controller with Assets Preview written in Swift

PPAssetsActionController Play with me ▶️ 🖐 If you want to play with me, just tap here and enjoy! 🎩 🕴 Show me 🎪 Try me 📲 The easiest way to try me

Read colors from Xcode assets file.

XcodePalette Read colors from Xcode assets file. How to Use Download the XcodePalette.Executable.zip of the latest release. Extract the XcodePalette U

Icons generator for XCode assets project

SwiftUI-PictGen Icons generator for XCode assets project. Small project in Swift

A swift package(SPM) with iOS UI component that loads and displays images from remote urls or local assets and displays in a slide-show form with auto scroll feature.

MDBannersView A swift package with an iOS UI component that loads and displays images from remote urls, local assets and displays in a slide-show form

BRD - the simple and secure wallet for bitcoin, ethereum, and other digital assets
BRD - the simple and secure wallet for bitcoin, ethereum, and other digital assets

BRD is the simple and secure wallet for bitcoin, ethereum, and other digital assets. Today, BRD is one of the largest non-custodial mobile wallets used by over 6 million users and protects an estimated nearly $7B USD.

Learning iOS Frontend: Aplikasi iOS Pemesanan Makanan dengan SwiftUI, WidgetKit, Google Fonts, dan Assets dari Figma
Learning iOS Frontend: Aplikasi iOS Pemesanan Makanan dengan SwiftUI, WidgetKit, Google Fonts, dan Assets dari Figma

Foody Aplikasi Foody adalah Aplikasi iOS Pemesanan Makanan dengan SwiftUI, WidgetKit, Google Fonts, dan Assets dari Figma untuk Mempelajari Ilmu Front

Beak 🐦 Peck into your Swift files from the command line

Beak 🐦 Peck into your Swift files from the command line Beak can take a standard Swift file and then list and run any public global functions in it v

Command line tool for exporting resources and generating code from your Figma files
Command line tool for exporting resources and generating code from your Figma files

Fugen Fugen is a command line tool for exporting resources and generating code from your Figma files. Currently, Fugen supports the following entities

AudioPlayer is syntax and feature sugar over AVPlayer. It plays your audio files (local & remote).

AudioPlayer AudioPlayer is a wrapper around AVPlayer. It also offers cool features such as: Quality control based on number of interruption (buffering

LicensePlist is a command-line tool that automatically generates a Plist of all your dependencies, including files added manually
LicensePlist is a command-line tool that automatically generates a Plist of all your dependencies, including files added manually

LicensePlist is a command-line tool that automatically generates a Plist of all your dependencies, including files added manually(specifi

A lightweight app to play videos from the Files app in a better (dark) interface which avoids losing your playback position.
A lightweight app to play videos from the Files app in a better (dark) interface which avoids losing your playback position.

Playerly Playerly is a very lightweight Swift app that allows you to select a file (video or movie) from the built in Document Browser, and play it in

Comments
  • Fixes pattern for Swift and added pattern for Objective-C.

    Fixes pattern for Swift and added pattern for Objective-C.

    Hi,

    I've created a PR for the 'pattern-matching'. For Swift the pattern (\\w+) was used, but this will not match dashes in filenames. So I decided to put the pattern in a variable and use that for a various types.

    Also added support for de default Objective-C call

    opened by fguchelaar 4
  • Cocoapods support

    Cocoapods support

    Hey there,

    Was looking for exactly this tool for my project, but I like to only use Cocoapods for dependencies. So I made this into a Cocoapod. It's my first time doing a Cocoapod so it's not quite "production ready" and the example project doesn't work, but it's a start. I'm using it as a pod in one of my other projects.

    Be aware I did make several breaking changes to the AssetChecker.swift file, including renaming it and refactoring it some. We can continue to iterate on it if you want.

    opened by joeboyscout04 3
  • What if uses pdf

    What if uses pdf

    I am using pdf file for Xcode project in place of image 1x,2x,3x. /Users/Akiran/Documents/WorkSpace/ProjectName/Resource/Images.xcassets:: error: [Asset Missing] AssertName

    Its shows Assert Missing any solution for this?

    opened by arishanapalli 0
  • Find asset catalogs automatically

    Find asset catalogs automatically

    Hey! I finally had a little time to complete a project which I was wanting to do for a while, supporting multiple asset catalogs and finding the asset catalogs automatically within the source. So now you can just add

    ${PODS_ROOT}/AssetChecker/run

    into your Build Phases and it should just work.

    I also changed the error output so that it will link to the file where the asset is missing instead of the asset catalog. I think this is a bit more helpful.

    I also added some images for testing in the sample project, as well as some instances of errors and warnings. The sample project throws the correct AssetChecker errors and warnings.

    Hopefully you can find some time to review these additions. This was a pretty large refactoring of the script file. I've tested it in two of my projects.

    opened by joeboyscout04 0
Releases(0.2.0)
Owner
Fresh
Simple iOS tools to solve problems 99% of us have.
Fresh
SwiftGen is a tool to automatically generate Swift code for resources of your projects

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Jan 5, 2023
An Xcode plug-in to format your code using SwiftLint.

SwiftLintXcode An Xcode plug-in to format your code using SwiftLint. Runs swiftlint autocorrect --path CURRENT_FILE before *.swift file is saved. IMPO

Yuya Tanaka 348 Sep 18, 2022
All new design. Inspect your iOS application at runtime.

Peek: All new design Peek 5 with an all new design and all new features. Whether you're a developer, designer or QA/tester, Peek can help you at all s

Shaps 2.6k Dec 17, 2022
Save development time! Respresso automatically transforms and delivers your digital assets into your projects

Respresso Android client Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects. It allows you to simply import

Respresso 11 May 27, 2021
Save development time! Respresso automatically transforms and delivers your digital assets into your projects

Respresso iOS client Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects. It allows you to simply import the

Respresso 50 May 1, 2021
Localization/I18n: Incrementally update/translate your Strings files from .swift, .h, .m(m), .storyboard or .xib files.

Installation • Configuration • Usage • Build Script • Donation • Migration Guides • Issues • Contributing • License BartyCrouch BartyCrouch incrementa

Flinesoft 1.3k Jan 1, 2023
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Dec 31, 2022
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Jan 3, 2023
A Mac utility to help download your Jamf assets.

Jade - Jamf Asset Download Extreme A Mac utility to help download your Jamf Assets: Features List and download the following Jamf assets: Jamf Pro Jam

Nindi Gill 7 Dec 5, 2022
AVXCAssets Generator takes path for your assets images and creates appiconset and imageset for you in just one click

AVXCAssets Generator Often while developing an app, We ran into a condition when we need to scale images to each and every aspect ratios for icons and

Angel Vasa 339 Dec 6, 2022