Voltar ao ranking

onevcat/FengNiao

Swift

A command line tool for cleaning unused resources in Xcode.

command-line-toolresourcesslimxcodeimagescleanupswift
Crescimento de estrelas
Estrelas
3.6k
Forks
246
Crescimento semanal
Issues
24
1k2k3k
mar. de 2017abr. de 2020jun. de 2023jul. de 2026
README

FengNiao

What

FengNiao is a simple command-line util to delete unused image resource files from your Xcode project.

How

Install

Mint

Mint is a tool that installs and runs Swift command line tool packages. Make sure you have Xcode installed, then:

> brew install mint
> mint install onevcat/fengniao

Compile from source

> git clone https://github.com/onevcat/FengNiao.git
> cd FengNiao
> swift build -c release

# Then copy the executable to your PATH, such as `/usr/local/bin`
> sudo cp .build/release/FengNiao /usr/local/bin/fengniao

FengNiao should be compiled, tested and installed into the /usr/local/bin.

Usage

Just navigate to your project folder, then:

> fengniao

It will scan current folder and all its subfolders to find unused images, then ask you whether you want to delete them. Please make sure you have a backup or a version control system before you deleting the images; it will be an un-restorable operation.

FengNiao supports some arguments. You can find it by:

> fengniao --help

  -p, --project:
      Root path of your Xcode project. Default is current folder.
  --force:
      Delete the found unused files without asking.
  -e, --exclude:
      Exclude paths from search.
  -r, --resource-extensions:
      Resource file extensions need to be searched. Default is 'imageset jpg png gif pdf'
  -f, --file-extensions:
      In which types of files we should search for resource usage. Default is 'm mm swift xib storyboard'
  --skip-proj-reference:
      Skip the Project file (.pbxproj) reference cleaning.
      By skipping it, the project file will be left untouched. 
      You may want to skip ths step if you are trying to build multiple projects with dependency and keep .pbxproj unchanged while compiling.
  --xcode-warnings:
      Print results as xcode warnings and return non zero code if any.
  --list-only:
      List unused files and exit without prompting.
  --version:
      Print version.
  -h, --help:
      Print this help message.

A more daily-work usage under a project could be:

> fengniao --project . --exclude Carthage Pods

This will search in current folder, but skip the Carthage and Pods folder, in which there might be some third party resources you do not want to touch.

Use with Xcode build phase

It is easy to integrate FengNiao into your Xcode build process. By doing so, you could ensure your project being cleaned every time you build your project.

Add a "Run Script" phase in the Build Phases tab:

Then drag it above of "Copy Bundle Resources", editing its content to something like this:

fengniao --exclude Carthage --force

It is recommended to exclude vendor's folders like Pods or Carthage. Since you do not have a chance to confirm the result, you also need to add --force option.

App Version

An GUI app version of FengNiao is also available. You can find it under the App folder. We do not provide a pre-built binary for it. If needed, please build it by yourself. Thank you for @ldakhoa's contribution!

How it works

  1. Extract resource file names (default file type: ["imageset", "jpg", "png", "gif", "pdf"]) in these folders ["imageset", "launchimage", "appiconset", "bundle”].
  2. Use regular expression to search all string names in files (default files type: ["m", "mm", "swift", "xib", "storyboard", "plist"]).
  3. Exclude all used string names from resources files, we get all unused resources files.

License and Information

FengNiao is open-sourced as MIT license. The name of this project comes from the Chinese word 蜂鸟 (hummingbird), which is the smallest bird in the world.

Submit an issue if you find something wrong. Pull requests are warmly welcome, but I suggest to discuss first.

You can also follow and contact me on Twitter or Sina Weibo.

Learning to Create

I streamed the way I created this tool as a live-coding session in a live platform in China. You can learn how to create a project with Swift Package Manager, how to apply Protocol-Oriented Programming (POP) in the project, and how to develop in a BDD way as well as write good tests there.

It is a paid series lesson in Chinese. If you are interested in it, please check and watch the links below:

Repositórios relacionados
rtk-ai/rtk

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Rustcrates.ioApache License 2.0agentic-codingai-coding
rtk-ai.app
72.4k4.5k
BurntSushi/ripgrep

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Rustcrates.ioThe Unlicenseripgreprecursively-search
66.4k2.7k
Unitech/pm2

Node.js/Bun Production Process Manager with a built-in Load Balancer.

JavaScriptnpmOtherpm2nodejs
pm2.keymetrics.io/docs/usage/quick-start/
43.2k2.7k
ajeetdsouza/zoxide

A smarter cd command. Supports all major shells.

Rustcrates.ioMIT Licensezcommand-line
crates.io/crates/zoxide
38.2k852
ggreer/the_silver_searcher

A code-searching tool similar to ack, but faster.

CApache License 2.0command-line-toolc
geoff.greer.fm/ag/
27.1k1.4k
spicetify/cli

Command-line tool to customize Spotify client. Supports Windows, macOS, and Linux.

JavaScriptnpmGNU Lesser General Public License v2.1spotifycustomization
spicetify.app
23.8k898
uutils/coreutils

Cross-platform Rust rewrite of the GNU coreutils

Rustcrates.ioMIT Licenserustcoreutils
uutils.org
23.8k2k
gitui-org/gitui

Blazing 💥 fast terminal-ui for git written in rust 🦀

Rustcrates.ioMIT Licenserusttui
22.3k751
extrawurst/gitui

Blazing 💥 fast terminal-ui for git written in rust 🦀

Rustcrates.iorusttui
18.9k582
wting/autojump

A cd command that learns - easily navigate directories from the command line

PythonPyPIOtherautojumppython
16.9k709
ast-grep/ast-grep

⚡A CLI tool for code structural search, lint and rewriting. Written in Rust

Rustcrates.ioMIT Licensecodemodlinter
ast-grep.github.io
15.1k417
sqshq/sampler

Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.

GoGo ModulesGNU General Public License v3.0shellvisualization
sampler.dev
14.7k667