How to find unused images in an Xcode project?

前端 未结 14 1619
旧时难觅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:45

    For files which are not included in project, but just hang-around in the folder, you can press

    cmd ⌘ + alt ⌥ + A

    and they won't be grayed out.

    For files which are not referenced neither in xib nor in code, something like this might work:

    #!/bin/sh
    PROJ=`find . -name '*.xib' -o -name '*.[mh]'`
    
    find . -iname '*.png' | while read png
    do
        name=`basename $png`
        if ! grep -qhs "$name" "$PROJ"; then
            echo "$png is not referenced"
        fi
    done
    

提交回复
热议问题