FengNiao

What is the fengniao

FengNiao is a command line tool developed by iOS onevcat using Swift and open source. Github address is here: github.com/onevcat/Fen…

What’s more, the first version of Meow God development was done in Code Online. What does that mean? At that time, Miaoshen opened a live broadcast, and the audience could directly see the whole process of development of this tool. During the process, Miaoshen would always explain the ideas and development skills. At that time, I didn’t see the live broadcast, feeling that I lost 100 million yuan, but fortunately, this tool has been maintained, benefiting more people.

So without further ado, let’s see how to use this tool!

How to install

Install with source code: Open the command line and do the following

> git clone https://github.com/onevcat/FengNiao.git
> cd FengNiao
> ./install.sh
Copy the code

After a while, fengniao will automatically compile and install to the */usr/local/bin* directory.

How to use

CD to the file directory where your project resides. 2. Directly use fengniao command

> 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'
  --version:
      Print version.
  -h, --help:
      Print this help message.
Copy the code

A more common operation is to find only images in the current project, not resources in Pod and Carthage:

> fengniao --project . --exclude Carthage Pods
Copy the code

If you want to check for unwanted image resources and remove them every time you build, you can do that too

fengniao --exclude Carthage Pods --force
Copy the code

Note: The Run Script needs to be added before “Copy Bundle Resources”, otherwise the images in the project are already compiled into the project and cannot be deleted.

What principle

Actually, the principle of Fengniao is relatively simple

1. Search for [” Imageset “, “JPG “,” PNG “, “GIF “,” PDF “] files under [” Imageset “, “LaunchImage “,” Appiconset “, “Bundle “].

2. In the project file with the suffix [“m”, “mm”, “swift”, “xib”, “storyboard”, “plist”], find the file name found in the first step. The string matches.

3. Get all the unused resource names, done

Dear friends, what are you waiting for? Hurry up and use Fengniao to slim down your APP! Give it a thumbs up if you think it works!