iOS 清理Xcode项目中没有使用到的图片资源和类文件

接手到一个旧的项目,但是发现里面有太多的无用资源,包括升级app后,一些无用的图片资源并没有被删掉,导致app在打包成ipa包以后,文件变大.手边这个项目IM要更换成环信的IM,之前的一些旧的SDK,包括一些无用的类和资源,无疑是一堆垃圾,如果你任性的通过复制图片名称到项目中去查找,一个个排查,那样真的好烦,而且没有什么技术含量.当然你还要留意是否有些图片资源的加载采用是字符串拼接.
今天找到一个好用的工具,拿来给大家分享,希望大家把更多的时间花在技术提高上.

关于无用图片资源

LSUnusedResources

LSUnusedResources 感谢改工具开发者 GitHub链接 https://github.com/tinymind/LSUnusedResources
A Mac App to find unused images and resources in an XCode project. It is heavily influenced by jeffhodnett‘s Unused, but Unused is very slow, and the results are not entirely correct. So I made some performance optimization, the search speed is more faster than Unused.

Usage

It's an useful utility tool to check what resources are not being used in your Xcode projects. Very easy to use:

  1. Click Browse.. to select a project folder.
  2. Click Search to start searching.
  3. Wait a second, the results will be shown in the tableview.

Feature

Check Ignore similar name to ignore the resources which referenced by string concatenation.

For example:

You import some resources like:

icon_tag_0.png
icon_tag_1.png
icon_tag_2.png
icon_tag_3.png

And using in this way:

NSInteger index = random() % 4;
UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"icon_tag_%d", index]];

icon_tag_x.png should not be shown as unused resource, we should ignore them.

Installation

Requirements

Requires OS X 10.7 and above, ARC.


关于没有使用到的类文件, 使用前实现备份

!!!!!! 如果你项目中有使用到xib和storyboard 一定要注意,这个工具并不检测storyboard,坑啊!回过头来我才知道为啥有的界面app会直接挂掉,因为找不到相关类文件呀!还要一步步检测 ,慎重使用!
连接 https://github.com/CatchZeng/CATClearProjectTool

CATClearProjectTool

clear objective-c project unused class file

Please backup before use it!

原文地址:https://www.cnblogs.com/chao8888/p/6690001.html