制作一個簡單的命令行工具,使用mac連接越獄手機后,可使用終端輸出自己制作的命令
1.創(chuàng)建iOS項目TestCommandLine,刪除一些無用的文件,如圖

main.png
main函數(shù)寫代碼
#import <UIKit/UIKit.h>
int main(int argc, char * argv[]) {
@autoreleasepool {
// 使用NSLog左邊會有一些打印時間等信息
printf("text command Line\n");
// 刪除程序入口App啟動方法
return 0;
}
}
2.選中真機設備,edit scheme ->run->release ->編譯

build.jpeg
3.products ->右鍵show in finder ->找到 TestCommandLine.app->右鍵 show in finder->TestCommandLine

91372F53-7C85-46D0-9291-046ACEF4AF0A.png
4.使用iFunBox->文件系統(tǒng)->usr->bin,這個文件夾存放著終端命令.把TestCommandLine放到這個路徑文件夾下
5.終端輸入指令
TestCommandLine
輸出
-sh: /usr/bin/TestCommandLine: Permission denied
6.添加權限
chmod +x /usr/bin/TestCommandLine
再次輸入指令,輸出
text command Line
并且輸入Tes敲tab鍵會自動補全
使用file命令查看這個TestCommandLine
file TestCommandLine
輸出
TestCommandLine: Mach-O universal binary with 2 architectures: [arm_v7:Mach-O executable arm_v7] [arm64:Mach-O 64-bit executable arm64]
TestCommandLine (for architecture armv7): Mach-O executable arm_v7
TestCommandLine (for architecture arm64): Mach-O 64-bit executable arm64
說明制作的這個TestCommandLine是一個可執(zhí)行的Mach-O文件