iOS越獄:命令行工具學習

制作一個簡單的命令行工具,使用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文件

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容