How to find unused images in an Xcode project?

前端 未结 14 1554
旧时难觅i
旧时难觅i 2020-12-07 06:57

Has anyone a one-line to find unused images in an Xcode project? (Assuming all the files are referenced by name in code or the project files - no code generated file names.)

14条回答
  •  囚心锁ツ
    2020-12-07 07:47

    I made a very slight modification to the excellent answer provided by @EdMcManus to handle projects utilizing asset catalogs.

    #!/bin/bash
    
    for i in `find . -name "*.imageset"`; do
        file=`basename -s .imageset "$i"`
        result=`ack -i "$file" --ignore-dir="*.xcassets"`
        if [ -z "$result" ]; then
            echo "$i"
        fi
    done
    

    I don't really write bash scripts, so if there are improvements to be made here (likely) let me know in the comments and I'll update it.

提交回复
热议问题