1. 用Theos新建tweak工程“iOSREGreetings” 新建iOSREGreetings工程的命令如下: snakeninnysiMac:Code snakeninny$ /opt/theos/bin/nic.pl NIC 2.0 - New Instance Creator ------------------------------ [1.] iphone/application [2.] iphone/cydget [3.] iphone/framework [4.] iphone/library [5.] iphone/notification_center_widget [6.] iphone/preference_bundle [7.] iphone/sbsettingstoggle [8.] iphone/tool [9.] iphone/tweak [10.] iphone/xpc_service Choose a Template (required): 9 Project Name (required): iOSREGreetings Package Name [com.yourcompany.iosregreetings]: com.iosre.iosregreetings Author/Maintainer Name [snakeninny]: snakeninny [iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.apple.springboard [iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: Instantiating iphone/tweak in iosregreetings/... Done.
%hook SpringBoard - (void)applicationDidFinishLaunching:(id)application { %orig; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Come to http://bbs.iosre.com for more fun!" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } %end
THEOS_DEVICE_IP = iOSIP ARCHS = armv7 arm64 TARGET = iphone:latest:8.0 include theos/makefiles/common.mk TWEAK_NAME = iOSREGreetings iOSREGreetings_FILES = Tweak.xm iOSREGreetings_FRAMEWORKS = UIKit include $(THEOS_MAKE_PATH)/tweak.mk after-install:: install.exec "killall -9 SpringBoard" 编辑后的control内容如下: Package: com.iosre.iosregreetings Name: iOSREGreetings Depends: mobilesubstrate, firmware (>= 8.0) Version: 1.0 Architecture: iphoneos-arm Description: Greetings from iOSRE! Maintainer: snakeninny Author: snakeninny Section: Tweaks Homepage: http://bbs.iosre.com
以上代码非常简单,当SpringBoard的applicationDidFinishLaunching:函数得到调用时,代表SpringBoard的启动过程已经结束。钩住(hook)这个函数,调用%orig完成它的原始操作,然后弹出一个自定义的UIAlertView;这样一来,每次重启SpringBoard都会弹出一个对话框。你看懂了吗?