gpt4 book ai didi

ios - 为什么我的 Tweak 不能正常工作?

转载 作者:行者123 更新时间:2023-11-29 12:54:26 25 4
gpt4 key购买 nike

我正在为运行 IOS 7 的 iPhone 制作我的第一个 MobileSubstrate 调整。

我正在使用 this tutorial .

本教程解释了 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

最佳答案

launch 适用于 iOS 6,您需要在 iOS 7 上使用 launchFromLocation:

@interface SBIcon : NSObject
- (void)launch; // iOS 6
- (void)launchFromLocation:(NSInteger)location; //iOS 7
@end

关于ios - 为什么我的 Tweak 不能正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21511697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com