剛開始配置Theos環(huán)境的時候各種踩坑,裝好了又卸載,各種問題,各種嘗試之后總結出了一下的方法,也是收集各方大神的資料綜合,做一個記錄方便以后自己使用也分享給各位。
1.如果有多個Xcode選擇一個Xcode路徑,只有一個Xcode可忽略此步驟
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
2.下載Theos
export THEOS=/opt/theos ? 配置環(huán)境變量
sudo git clone git://github.com/DHowett/theos.git $THEOS ?下載Theos
注:后面使用可能還需要更新Theos
3.下載ldid
http://joedj.net/ldid?
復制下載的ldid到/opt/theos/bin
sudo chmod 777 /opt/theos/bin/ldid ?給ldid賦權限
4.配置CydiaSubstrate
用iFile連上iPhone,將iOS上
/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate
拷貝到電腦上然后改名為libsubstrate.dylib?
拷貝到/opt/theos/lib 中.
5.配置dkpg
sudo port install dpkg
如果是下載的dpkg-deb需要執(zhí)行 sudo chmod 777 /opt/theos/bin/dpkg-deb? 給dpkg-deb賦權限
二、創(chuàng)建Tweak工程
1.cd到某一個自己想要保存的文件夾執(zhí)行下面語句
/opt/theos/bin/nic.pl
注:這里可能會報錯出現Theos過期需要執(zhí)行git指令,有提示,cd到these文件夾下,然后根據提示輸入sudo git submodule update --init --recursive 【命令根據提示粘貼】執(zhí)行完這句話再回到創(chuàng)建工程/opt/theos/bin/nic.pl步驟
出現下面這個
NIC 2.0 - New Instance Creator
------------------------------
[1.] iphone/activator_event
[2.] iphone/application_modern
[3.] iphone/cydget
[4.] iphone/flipswitch_switch
[5.] iphone/framework
[6.] iphone/ios7_notification_center_widget
[7.] iphone/library
[8.] iphone/notification_center_widget
[9.] iphone/preference_bundle_modern
[10.] iphone/tool
[11.] iphone/tweak
[12.] iphone/xpc_service
Choose a Template (required): 11 ?【選擇你想要構建的工程類型,這里選的Tweak】
Project Name (required): tweak ?【工程名】
Package Name [com.yourcompany.tweak]: com.app.tweak 【包名,相當于bundleId】
Author/Maintainer Name [apple2015]: bean 【作者】
[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.apple.spingboard?
[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: SpringBoard
Instantiating iphone/tweak in tweak/...
Done.

2.修改Makefile
THEOS_DEVICE_IP = 192.168.1.128 【iP改成自己手機的iP,手機和電腦必須在同一wifi下】
ARCHS = armv7 arm64
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = tweak
tweak_FILES = Tweak.xm? 【tweak這里的名字是工程名】
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"
3.修改Tweak.xm
#import <UIKit/UIKit.h>
#import <SpringBoard/SpringBoard.h>
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome"
message:@"First Blood"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
%orig;
}
%end
注:這里代碼的意思是勾出springboard的初始化方法。
之所以勾springboard是因為它是越獄手機一直在后臺運行的東西。
4.配置環(huán)境變量
export THEOS=/opt/theos/
export THEOS_DEVICE_IP=192.168.1.128 【手機的ip地址】
注:在之后執(zhí)行make package install命令中出現了tool.mk notfound 或者xx.mk notfound就需要配置這個東西了。
5.打包安裝工程到手機
cd 到有makeFile的文件路徑下
make package install?
也可以分解步驟一步一步走
make
make package
make install
注:如果出現錯誤,一個可能是剛剛第4步提到的錯誤,還有一個就是第1步提到的錯誤,進行相應的修改即可
這里還會提示你輸入兩次密碼,如果手機沒有設置過密碼的話,就是初始的密碼:alpine
執(zhí)行完成你就等著手機重新加載,然后露出你得意的微笑。
三、小總結
1.如果你安裝完成之后發(fā)現/opt/theos/vendor/這里面是空的,就說明需要執(zhí)行第二步驟的第1步注意事項;
2.如果你發(fā)現make成功之后還想make 發(fā)現報了Nothing to be done for `internal-library-compile,那就把你剛才創(chuàng)建出來的obj刪掉和packages刪掉 , 然后顯示隱藏文件, 你就會發(fā)現和obj同一個目錄有一個.theos , 吧.theos里面的東西刪掉就好了
或者最狠的就是重新開始工程,或者make clean
3.有正向經驗的小伙伴可以簡單理解為makefile相當于plist文件,Tweak.xm相當于要寫代碼的工程。
四、開啟你的逆向之路吧!??!
注:以上提到的文件如需要下載的可以用我的github下載,好用的話給個start吧。
https://github.com/BeanMan/tweakPackage
參考文章:http://blog.csdn.net/app_ios/article/details/52596230
http://www.itdecent.cn/p/3c1d71c880ca
站在巨人的肩膀上才有這些總結
菜鳥走向大牛,大家共同前進,如果覺得不錯,請給個贊/關注。
一起交流學習,有問題隨時歡迎聯系,郵箱:383708669@qq.com