theos - tweak的開發過程.png
theos - tweak的運行過程.png
安裝
安裝簽名工具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
theos-tweak實現過程
image.png