我正在为运行 IOS 7 的 iPhone制作我的第一个MobileSubstrate调整。
我正在使用本教程。
本教程解释了Hooking
他的源代码的基础知识并提供了一个 git hub 示例。
为了测试他编写的代码是否有效,并且为了让我了解theos编译终端,我编译了他的项目。
该项目假设显示一个UIAlert
应用程序何时启动,并在 iPhone 的设置应用程序中设置开关状态为开或关。
将此编译的 deb 安装到我的 iphone 上时,添加了设置页面,因此我可以打开或关闭该功能,但是当该功能打开时,警报不会显示。
这是我的 Tweak.xm 代码:
@interface SBApplicationIcon
-(void)launch;
-(id)displayName;
@end
%hook SBApplicationIcon
-(void)launch
{
NSString *appName = [self displayName];
NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithContentsOfFile:
[NSString stringWithFormat:@"%@/Library/Preferences/%@", NSHomeDirectory(), @"com.AndyIbanez.NotifierSettings.plist"]];
NSNumber* shouldNotify = [settings objectForKey:@"alertLaunch"];
if([shouldNotify boolValue] == YES)
{
NSString *message = [NSString stringWithFormat:@"The app %@ has been launched", appName, nil];
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:appName message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert1 show];
[alert1 release];
}
%orig;
}
%end
这是我正在关注且引人注目的 GitHub 示例文件:https ://github.com/AndyIbanez/TutorialProjects/tree/master/launchnotifier