場景
隨著項目的不斷集成戳杀,可能在項目中存在一些重復(fù)的文件
1步做、有些類使用Xcode可能查看不到枝缔,但是show in finder的時候可能就看到了布疙,這種可能是因為誤操作,忘記刪除源文件愿卸,只是刪除了引用導(dǎo)致
2、項目中一些庫存在多份資源截型,比如face趴荸,根據(jù)實際情況,看是否可以干掉一份
3宦焦、可能項目中存在一些重名的圖片資源发钝,這種的就直接對我們的項目展示產(chǎn)生影響了
4、可能會重復(fù)導(dǎo)入一些.a之類的波闹,重復(fù)導(dǎo)入.a酝豪,可能不會報錯
。精堕。孵淘。。歹篓。
搞起
搞一個小腳本來檢測一把瘫证,查找陰暗中的重復(fù)文件......
RepeatFileFindPro.py
腳本地址
python3 RepeatFileFindPro.py -f .png,.jpg,.jpeg,.bundle,.framework,.a,.h,.m,.imageset -p /Users/a58/Desktop/XXX/Project -e Assets.xcassets,Pods/Headers
參數(shù)說明:
-f 需要查找的文件類型,多個用逗號隔開庄撮。不僅可以查文件背捌,還可以查文件夾比如.bundle
-p 工程目錄
-e 不查詢的路徑,比如在某個路徑下查到重復(fù)文件洞斯,看是否在當(dāng)前路徑下毡庆,進行排除,比如排除Assets.xcassets烙如,是因為Assets.xcassets中圖片真正的名字參考意義不大么抗,排除Pods/Headers,避免重復(fù)檢測Pods/Headers/Public&Pods/Headers/Private沒有參考價值,多個用逗號隔開
效果:
重復(fù)文件【SingleObjc2.h】 重復(fù)數(shù)量-- 【2個】
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/SingleObjc2.h
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/Resource/SingleObjc2.h
重復(fù)文件【libAAAA.a】 重復(fù)數(shù)量-- 【2個】
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/libAAAA.a
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/wmda/libAAAA.a
重復(fù)文件【W(wǎng)MDA.h】 重復(fù)數(shù)量-- 【2個】
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/WMDA.h
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/wmda/WMDA.h
重復(fù)文件【SingleObjc2.m】 重復(fù)數(shù)量-- 【2個】
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/SingleObjc2.m
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/Resource/SingleObjc2.m
重復(fù)文件【weibo.imageset】 重復(fù)數(shù)量-- 【2個】
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/Assets.xcassets/weibo.imageset
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/Assets.xcassets/Image/weibo.imageset
重復(fù)文件【isd_cap_success@2x.png】 重復(fù)數(shù)量-- 【2個】
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/Resource.bundle/isd_cap_success@2x.png
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/Resource/Resource11.bundle/isd_cap_success@2x.png
重復(fù)文件【isd_cap_success@3x.png】 重復(fù)數(shù)量-- 【2個】
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/Resource.bundle/isd_cap_success@3x.png
/Users/a58/Desktop/smallDemo/ImagesDemo001/ImagesDemo001/Resource/Resource11.bundle/isd_cap_success@3x.png
在路徑 /Users/a58/Desktop/smallDemo/ImagesDemo001 中,排除文件夾類型【Assets.xcassets, Pods/Headers】
找到【.png, .jpg, .jpeg, .bundle, .framework, .a, .h, .m, .imageset】類型的重復(fù)文件【14】個
image.png