接手到一個舊的項目,但是發現里面有太多的無用資源,包括升級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:
- Click
Browse..
to select a project folder. - Click
Search
to start searching. - 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
- Download: LSUnusedResources.app.zip
- Or build and run the project using XCode.
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