1、Theos是iOS越狱插件开发的集成环境,它可以创建工程,调用XCode的命令行工具编译、ldid签名打包,并提供上传手机、安装等一系列操作,安装成功后可以Cydia的已安装插件中看到。
2、安装ldid&dpkg
2.1、安装ldid
2.1.1、参考链接:https://brewinstall.org/Install-ldid-on-Mac-with-Brew/
2.1.2、安装命令:
1 | yusian@SianMac2:~/Documents/Reverse$ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null |
1 | yusian@SianMac2:~/Documents/Reverse$brew install ldid |
2.1.3、必须要说的是,第一条命令是安装Homebrew,也许你Mac上早安装过Homebrew了,但也强制建议再执行一次该命令,可将Homebrew升级到最新版本,这里可能会是个坑!!因为XCode10现在废弃了以前的libstd++这个c++库,取而代之的是libc++,如果是XCode10,并且没有升级到最新Homebrew,可能在brew install ldid时报错
2.2、安装dpkg
2.2.1、dpkg是Theos依赖的工具之一,dpkg是Debian Packager的缩写。我们可以使用dpkg来制作deb,Theos开发的插件都将会以deb的格式进行发布的。所以我在安装Theos之前要安装dpkg
2.2.2、安装命令
1 | yusian@SianMac2:~/Documents/Reverse$brew install dpkg |
2.2.3、这里又要啰嗦一句,如果不安装dpkg,可能后续你一切顺利,在最后关头要将deb打包安装到手机上时报错了,我踩到的坑是这样的:
1 2 3 4 5 6 7 | yusian@SianMac2:~/Desktop/tingtweak$ make package > Making all for tweak tingtweak… make[2]: Nothing to be done for `internal-library-compile'. > Making stage for tweak tingtweak… dm.pl: building package `com.yusian.tingtweak:iphoneos-arm' in `./packages/com.yusian.tingtweak_0.0.1-2+debug_iphoneos-arm.deb' open2: exec of lzma -c6 failed at /Users/yusian/Documents/Reverse/theos/bin/dm.pl line 113. make: *** [internal-package] Error 2 |
敬请绕过….
3、安装Theos
3.1、github下载Theos项目:
1 | yusian@SianMac2:~/Desktop$ git clone --recursive https://github.com/theos/theos.git ~/Documents/Reverse/theos |
3.2、配置环境变量,vim ~/.bash_profile 打开该文件后,在尾部添加
1 2 3 | #theos export THEOS=~/Documents/Reverse/theos export PATH=$THEOS/bin:$PATH |
保存退出后,执行source ~/.bash_profile命令使环境变量生效
3.3、在终端输入nic.pl,如果能正常执行,则Theos安装配置搞定!
4、使用Theos创建插件项目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | yusian@SianMac2:~/Desktop$ nic.pl NIC 2.0 - New Instance Creator ------------------------------ [1.] iphone/activator_event [2.] iphone/application_modern [3.] iphone/application_swift [4.] iphone/cydget [5.] iphone/flipswitch_switch [6.] iphone/framework [7.] iphone/ios7_notification_center_widget [8.] iphone/library [9.] iphone/notification_center_widget [10.] iphone/preference_bundle_modern [11.] iphone/tool [12.] iphone/tool_swift [13.] iphone/tweak [14.] iphone/xpc_service Choose a Template (required): 13 Project Name (required): tingtweak Package Name [com.yourcompany.tingtweak]: com.yusian.tingtweak Author/Maintainer Name [yusian]: yusian [iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.gemd.iting [iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: Instantiating iphone/tweak in tingtweak/... Done. |
4.1、工程目录下共有4个文件:control、Makefile、xxxx.plist、Tweak.xm
4.2、Tweak.xm为需要更改的类及类方法,这个不在这里赘述;
4.3、编辑Makefile在顶部插入
1 2 | export THEOS_DEVICE_IP=127.0.0.1 export THEOS_DEVICE_PORT=2222 |
4.4、编译–>打包–>安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | yusian@SianMac2:~/Desktop/tingtweak$ make > Making all for tweak tingtweak… make[2]: Nothing to be done for `internal-library-compile'. yusian@SianMac2:~/Desktop/tingtweak$ make package > Making all for tweak tingtweak… make[2]: Nothing to be done for `internal-library-compile'. > Making stage for tweak tingtweak… dm.pl: building package `com.yusian.tingtweak:iphoneos-arm' in `./packages/com.yusian.tingtweak_0.0.1-10+debug_iphoneos-arm.deb' yusian@SianMac2:~/Desktop/tingtweak$ make install ==> Installing… (Reading database ... 1244 files and directories currently installed.) Preparing to unpack /tmp/_theos_install.deb ... Unpacking com.yusian.tingtweak (0.0.1-10+debug) over (0.0.1-9+debug) ... Setting up com.yusian.tingtweak (0.0.1-10+debug) ... install.exec "killall -9 SpringBoard" yusian@SianMac2:~/Desktop/tingtweak$ |
4.4.1、上述是正常的状态与结果,在make的时候有可能会报错,我的坑:
1 2 3 4 5 6 7 8 9 10 | yusian@SianMac2:~/Desktop/tingtweak$ make xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located xcrun: error: SDK "iphoneos" cannot be located ==> Error: You do not have any SDKs in /Library/Developer/CommandLineTools/Platforms/iPhoneOS.platform/Developer/SDKs or /Users/yusian/Documents/Reverse/theos/sdks. make: *** [before-all] Error 1 |
这个问题是说没有找到相对应的sdk,修改下SDK路径:
1 | yusian@SianMac2:~/Desktop/tingtweak$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/ |
4.4.2、make package可能的报错,前面有提到过,需要brew install dpkg安装dpkg。
5、差不多了,祝你好运!