前言
最近蘋果的熱更新和私有庫問題檢查的更嚴了,如果應用被拒,蘋果在拒絕信中會說到使用
strings
/
otool
nm
指令進行自查,是以總結了一些指令,友善查找和定位檔案内容相關資訊。
1、grep
- 作用:判斷是否包含字元串
- 使用示例:
grep -r "xxx” path
檢查是否包含(weixin)字元串:
grep -r "xxx” path.png
matches
表示包含。
2、strings
- 作用:find the printable strings in a object, or other binary, file
-
//檢查 a.out 檔案中含有 hello 字元串的位元組序列strings a.out | grep hello
- 檢查二進制是否含有關鍵詞的庫(比如檢查私有庫): strings a.out | grep hello.png
- 更多使用說明
man strings
3、otool
- 作用: object file displaying tool. (針對目标檔案的展示工具,用來發現應用中使用到了哪些系統庫,調用了其中哪些方法,使用了庫中哪些對象及屬性)
-
//檢視可執行程式都連結了那些庫otool -L path
//篩選是否連結了xxx庫otool -L path | grep "xxx"
//檢視支援的架構otool -D path
//output the Objective-C class structures and their defined methods.(輸出Object-C類結構以及定義的方法)otool -ov path
- 檢視該應用是否砸殼:
//cryptid 0(砸殼) 1(未砸殼) otool -l path | grep crypt.pngotool -l path | grep crypt
- 更多用法
man otool
4、nm
- 作用:display name list (symbol table). (顯示符号表)
-
//得到Mach-O中的程式符号表nm path
//目标檔案的所有符号nm -nm path
nm -nm path.png
符号表中标示為 undefined,意思是目标檔案引用了類_XXX(XXX庫),不過這并沒有實作它。
-
man nm
5、file
- 作用:determine file type. (判斷檔案類型)
-
file path
判斷.a/framework是靜态庫還是動态庫:
靜态庫:
file path - static Lib.png
動态庫:
file path - dynamically Lib.png
6、lipo
- 作用:create or operate on universal files(建立或處理通用檔案的工具)
-
// 判斷靜态庫所支援的平台 - i386 armv7 armv7s x86_64 arm64lipo -info 'file path'
// 删除靜态庫包括的i386平台lipo -remove i386 origin_xxx.a -output op_xxx.a
// 拆分靜态庫,隻保留i386 CPU架構lipo -thin i386 origin_xxx.a -output op_xxx.a
//對真機或者模拟器分别打出 .a 檔案合并lipo -create device_xxx.a simulator_xxx.a -output universal_xxx.a
參考閱讀
- "nm tool" Xcode manual page
- iOS-private-api-scanner/iOS私有API掃描工作總結· mrmign/iOS-private-api-scanner
- iOS-private-api-checker蘋果iOS私有API檢查工具
- iOS開發-如何判斷framework是動态庫或靜态庫以及framework靜态庫轉.a靜态庫
注:本文首發于 iHTCboy's blog ,如若轉載,請注明來源。