一、安装签名工具
- ???????????确保安装brew
-
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- ??利用brew?安装?ldid
-
$ brew install ldid
????????二、修改环境变量
- 编辑用户的配置文件
-
$ vim ~/.bash_profile
- 在.bash_profile文件后加入以下2行
-
export THEOS=~/theos export PATH=$THEOS/bin:$PATH
- ?.bash_profiel?????????????????????配置的环境变量立即生效,或者重启终端
三、下载theos
- ???建议在THEOS目录下下载代码(也就是刚才配置的???????????????~/theos???)
$ git clone --recursive https://github.com/theos/theos.git $THEOS
四、新建tweak
- cd???????????????????到一个存放项目代码的文件中
-
$ cd ~/Desktop $ nic.pl
- 选择iphone/tweak
输入数字选项
- 填写项目名称
- Project Name 项目名称
- Package Name 项目ID 随便写
- Author/Maintainer Name 作者,直接敲回车按照默认做法就行 默认是mac上的用户名
- [iphone/tweak] MobileSubstrate Bundle filter 需要修改的APP的bundle id , 可以通过Cycript查看APP的Bundle id
- [iphone/tweak] List of applications to terminate upon installation 直接敲回车 默认做法
-
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和端口号,可以添加到用户的配置文件中,编辑完毕后,$ source ~/.bash_profile让配置生效或者重启
-
$ 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
theos资料查询
目录结构:https://github.com/theos/theos/wiki/Structure
环境变量:http://iphonedevwiki.net/index.php/Theos
Logos??语法:http://iphonedevwiki.net/index.php/Logos
如果有额外的资源文件比如图片,放在项目的layout文件中,对应手机的根目录
theos-tweak的实现过程
编写Tweak代码
make:编译Tweak代码为动态库
make package :将dylib打包为deb文件
make install:将deb文件传送到手机上,通过Cydia安装deb
插件将会安装在???????/Library/MobileSubstrate/DynamicLibraries????文件中