如何在 Xcode 项目中找到未使用的图像? [英] How to find unused images in an Xcode project?

查看:27
本文介绍了如何在 Xcode 项目中找到未使用的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人在 Xcode 项目中查找未使用的图像?(假设所有文件都通过代码或项目文件中的名称引用 - 没有代码生成文件名.)

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.)

这些文件往往会在项目的整个生命周期中累积,并且很难判断删除任何给定的 png 是否安全.

These files tend to build up over the life of a project and it can be hard to tell if it's safe to delete any given png.

推荐答案

对于不包含在项目中,只是挂在文件夹中的文件,可以按

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

cmd ⌘ + alt ⌥ + A

它们不会变灰.

对于既没有在 xib 也没有在代码中引用的文件,这样的事情可能会起作用:

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

这篇关于如何在 Xcode 项目中找到未使用的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆