我的 theos 调整在添加自定义 dylib 文件后停止工作



我使用 Theos 创建了一个简单的调整,将黄色的 UIView 添加到应用程序窗口(没什么特别的(,它运行良好。然后我制作了一个dylib文件(称为AlertLib(,其中包含一个类(也称为AlertLib(,方法之一是:显示一个简单的UIAlertView。我将 AlertLib.dylib 复制到/opt/theos/lib 文件夹,将 AlertLib.h 复制到/opt/theos/include 文件夹。

我的生成文件看起来像这样:

export ARCHS = armv7 arm64
export TARGET = iphone:clang:latest:8.0
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = YellowSquare
YellowSquare_FILES = Tweak.xm
YellowSquare_FRAMEWORKS = UIKit Foundation
YellowSquare_LDFLAGS = -lAlertLib
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"

Tweak.xm文件看起来像这样:

#import "AlertLib.h"
%hook AppDelegate
- (void) applicationDidBecomeActive:(UIApplication *) application
{
static dispatch_once_t once;
dispatch_once(&once, ^{
UIView *yellowSquareView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
yellowSquareView.backgroundColor = [UIColor yellowColor];
UILabel *tweakLabel = [[UILabel alloc] initWithFrame:yellowSquareView.bounds];
tweakLabel.backgroundColor = [UIColor clearColor];
tweakLabel.text = @"TWEAK";
tweakLabel.font = [UIFont systemFontOfSize:25];
tweakLabel.textAlignment = NSTextAlignmentCenter;
[yellowSquareView addSubview:tweakLabel];
UIWindow *window = [UIApplication sharedApplication].keyWindow;
yellowSquareView.center = window.center;
[window addSubview:yellowSquareView];
[[AlertLib sharedInstance] showAlert];
});
%orig;
}
%end

之后,我编译了调整,并将其安装到设备上,没有错误。但是,现在调整不起作用,即应用程序窗口上没有添加黄色视图,也没有显示警报。如何正确嵌入自定义 dylib 文件进行调整?

从外观来看,我的赌注是AlertLib没有安装在设备上。如果"不工作"意味着应用程序崩溃,就会出现这种情况。
我想请求"不工作"的详细定义,并在可能的情况下编译 dylib。

我通过将自定义库作为子项目添加到我的调整中来解决我的问题。 我在调整的根目录中/opt/theos/bin/nic.pl运行命令,然后从列表中选择。它已自动添加为子项目。然后我将所需的文件添加到我的库中,它起作用了。

最新更新