Theos 环境配置安装
1.安装ldid
-
ldid
用来专门签名iOS可执行文件的工具,用以在越狱iOS中取代Xcode自带的codesign
。如果不安装,那么产生的deb
文件就安装不到手机上
brew install ldid
2.Theos安装
官方建议把Theos
安装在/opt/theos
目录下
sudo git clone --recursive https://github.com/theos/theos.git /opt/theos
然后把/opt/theos
的权限改为自己所拥有
sudo chown $(id -u):$(id -g) /opt/theos
3.环境变量
- 编辑配置文件:
vim ~/.bash_profile
export THEOS=/opt/theos
export PATH=/opt/theos/bin/:$PATH

- 更新立即生效
source ~/.bash_profile
- 查看是否生效:
echo $THEOS
,echo $PATH
如果关闭命令端,再打开就失效是因为采用了zsh
代替bash
,而zsh
加载的是~/.zshrc
文件,而.zshrc
文件中并没有定义任务环境变量。解决办法在~/.zshrc
文件最后,增加一行:
source ~/.bash_profile
然后立即生效
source ~/.zshrc
4.测试安装是否成功
在任意路径下输入nic.pl
nic.pl
NIC 2.0 - New Instance Creator
------------------------------
[1.] iphone/activator_event
[2.] iphone/application_modern
[3.] iphone/application_swift
[4.] iphone/flipswitch_switch
[5.] iphone/framework
[6.] iphone/library
[7.] iphone/preference_bundle_modern
[8.] iphone/tool
[9.] iphone/tool_swift
[10.] iphone/tweak
[11.] iphone/xpc_service
Choose a Template (required):
Tweak项目创建
1. 输入nic.pl
后,选择模板输入10
Choose a Template (required): 10
2.输入tweak
的工程名
Project Name (required): readerTweak
3.输入deb
包名(格式类似bundle Identifier
)
Package Name [com.yourcompany.readertweak]: com.lb.readertweak
4. 输入作者或维护人名字
Author/Maintainer Name [mac]: Lucky Blue
5. 输入tweak
作用的对象,就是需要需要HOOK
的APP
的bundle Identifier
[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.tencent.ied.app.comic
6.输入tweak
安装完成后需要重启的应用,以进程名表示,比如系统的桌面:
[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: SpringBoard
成功终端就会显示
Instantiating iphone/tweak in readertweak/...
Done.

成功后会生成下面四个文件

Tweak项目编写
在Makefile文件最上面加入下面两行代码
THEOS_DEVICE_IP:本机IP
THEOS_DEVICE_PORT:本机与iPhone通信的端口
export THEOS_DEVICE_IP=127.0.0.1
export THEOS_DEVICE_PORT=5757

删除所有Tweak.x
文件里默认的注释,然后输入如下
Logos官方文档
%hook ComicHomeViewController //%hook 类名
-(void)viewWillAppear:(BOOL)animated{
%orig;// %orig是Logos语法,先调用上一层的代码,跟oc的 [super xxxx]差不多的意思
//创建UIAlertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"注意"
message:@"这是第一个tweak项目"
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
}
%end
编译,打包和安装
make clean && make && make package && make install



网友评论