theos来开发插件

一、安装签名工具ldid

先确保安装了brew

$ /usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)" 

利用brew安装ldid

$ brew install ldid

二、修改环境变量

编辑用户的配置文件

$ vim ~/.bash_profile

在.bash_profie文件后面加入以下2行

export THEOS=~/theos
export PATH=$THEOS/bin:$PATH

让.bash_profiel配置的环境变量立即生效(或者重新打开终端)

$ source ~/.bash_profile

三、下载theos

建议$THEOS目录下载代码(也就是刚才配置的~/theos目录)

$ git clone --recursive https://github.com/theos/theos.git $THEOS

theos的bin目录中有nic.pl 、logify.pl,可通过以下命令查看

~/theos/bin zy$ ls -l
theos的bin目录

四、新建tweak项目

cd到一个存放项目代码的文件夹(比如桌面)

$ cd ~/Desktop
$ nic.pl

选择[11.] iphone/tweak


截屏2022-10-06 下午3.11.07.png

填写项目信息

Project Name (required): ting_tweak
Package Name [com.yourcompany.ting_tweak]: com.mj.ting
Author/Maintainer Name [MJ Lee]:
[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 ting_tweak/...
Done

五、编辑Makefile

在前面加入环境变量,写清楚通过哪个IP和端口访问手机
THEOS_DEVICE_IP
THEOS_DEVICE_PORT

export THEOS_DEVICE_IP=127.0.0.1
export THEOS_DEVICE_PORT=10010
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = ting_tweak
ting_tweak_FILES = Tweak.xm
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
    install.exec "killall -9 SpringBoard"

如果你不希望那个项目的Makefile都编写IP和端口环境变量,也可以添加到用户配置文件中

$vim ~/.bash_profile
export THEOS=~/theos
export PATH=$THEOS/bin:$PATH
export THEOS_DEVICE_IP=127.0.0.1
export THEOS_DEVICE_PORT=10010

$ source ~/.bash_profile

六、编写代码

打开Tweak.xm文件

%hook XMAdAnimationView
- (id)initWithImageUrl:(id)arg1 title:(id)arg2 iconType:(long long)arg3
jumpType:(long long)arg4
{
return nil; 
}
%end

%hook XMSoundPatchPosterView
- (id)initWithFrame:(struct CGRect)arg1
{
return nil; 
}
%end

七、编译-打包-安装
编译

make

打包成deb

make package

安装(默认会自动重启SpringBoard)

make install
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容