安装
安装签名工具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_profile文件后面加入以下2行
export THEOS=~/theos
export PATH=$THEOS/bin:$PATH
- 让.bash_profile配置的环境变量立即生效(或者重启终端)
$ source ~/.bash_profile
下载theos
- 建议在$THEOS目录下下载代码(也就是刚才配置的~/theos目录)
$ git clone --recursive https://github.com/theos/theos.git $THEOS
新建tweak项目
- cd到一个存放项目代码的文件夹
$ cd ~/Desktop
$ nic.pl
-
选择iphone/tweak
image.png -
填写项目信息
image.png
编辑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
可能的问题
1、 make package的错误
$ make package
Can't locate IO/Compress/Lzma.pm in @INC (you may need to install the
IO::Compress::Lzma module) (@INC contains: /Library/Perl/5.18/darwin-
thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-
thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2
/System/Library/Perl/5.18/darwin-thread-multi-2level
/System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-
multi-2level /System/Library/Perl/Extras/5.18 .) at
/Users/mj/theos/bin/dm.pl line 12.
BEGIN failed--compilation aborted at /Users/mj/theos/bin/dm.pl line 12.
make: *** [internal-package] Error 2
- 是因为打包压缩方式有问题,改成gzip压缩就行了
-- 修改dm.pl文件,用#注释掉下面两句
$ vim $THEOS/vendor/dm.pl/dm.pl
#use IO::Compress::Lzma;
#use IO::Compress::Xz;
-- 修改deb.mk文件的第6行压缩方式位gzip
$ vim $THEOS/makefiles/package/deb.mk
_THEOS_PLATFORM_DPKG_DEB_COMPRESSION ?= gzip
2、make错误
$ make
Error: You do not have an SDK in
/Library/Developer/CommandLineTools/Platforms/iPhoneOS.platform/Developer/S
DKs
- 是因为多个xcode导致的,需要指定一个Xcode
$ sudo xcode-select --switch
/Applications/Xcode.app/Contents/Developer/
$ make
> Making all for tweak xxx...
make[2]: Nothing to be done for `internal-library-compile'.
- 是因为之前编译过吗,需要清理缓存
$ make clean
$ make
文档
- 目录结构: https://github.com/theos/theos/wiki/Structure
- 环境变量:http://iphonedevwiki.net/index.php/Theos
- Logos语法:http://iphonedevwiki.net/index.php/Logos
网友评论