Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/freshOS/AssetChecker

๐Ÿ‘ฎSanitize your Assets.xcassets files
https://github.com/freshOS/AssetChecker

asset-catalog assets cleanup images ios resource script slim swift xcode

Last synced: about 2 months ago
JSON representation

๐Ÿ‘ฎSanitize your Assets.xcassets files

Lists

README

        

![Localize](https://raw.githubusercontent.com/s4cha/AssetChecker/master/banner.png)

# AssetChecker
[![Language: Swift](https://img.shields.io/badge/language-swift-f48041.svg?style=flat)](https://developer.apple.com/swift)
![Platform: iOS](https://img.shields.io/badge/platform-iOS-blue.svg?style=flat)
[![codebeat badge](https://codebeat.co/badges/7c6098dd-e48e-4283-a04e-2b74aeb80a2e)](https://codebeat.co/projects/github-com-s4cha-assetchecker)
[![License: MIT](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/s4cha/Localize/blob/master/LICENSE)
[![GitHub tag](https://img.shields.io/github/release/freshos/AssetChecker.svg)](https://github.com/freshOS/AssetChecker/releases)

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

![AssetChecker](https://raw.githubusercontent.com/s4cha/AssetChecker/master/xcodeScreenshot.png)

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](https://freshos.github.io/) 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:
```shell
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:

```shell
${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:

```shell
${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 :
```swift
// 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:

```swift
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](https://github.com/s4cha/AssetChecker/blob/master/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 :)