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

查看:69
本文介绍了如何在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天全站免登陆