4

我正在尝试让 theos 在 OSX Mavericks 上工作。我最近购买了一部 iPhone 5s,并从那时起越狱了。现在我正在尝试让 Theos 正常工作,这样我就可以再次开始进行一些调整。我让它在 OSX Lion 和 IOS 5 和 6 上运行。我有一个非常简单的程序,它应该在应用程序启动时显示 UIAlert。问题是,当我运行 make 命令以尝试编译我的代码时,我收到此错误:

Making all for tweak test...
 Preprocessing Tweak.xm...
 Compiling Tweak.xm...
 Linking tweak test...
Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_UIAlertView", referenced from:
      objc-class-ref in Tweak.xm.b0410391.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [obj/test.dylib.1cc22e7c.unsigned] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [test.all.tweak.variables] Error 2
Williams-MacBook-Pro-2:test williamfsmillie$ 

这是我的 Tweak.xm 代码:

%hook SBApplicationIcon

-(void)launch{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TEST" message:@"message...." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    %orig;
}

%end

还有我的makefile:

export SDKVERSION=7.0

include theos/makefiles/common.mk

TWEAK_NAME = test
test_FILES = Tweak.xm
ARCHS = armv7 arm64
test_FRAMEWORKS = UIKit

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
    install.exec "killall -9 SpringBoard"

谢谢!

4

6 回答 6

6

这是一个老问题,但我仍然认为我应该为有同样问题的人回答这个问题。您需要调用objc_getClass它才能工作,如下所示:

UIAlertView *alert = [[objc_getClass("UIAlertView") alloc] initWithTitle:@"TEST" message:@"message...." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

请注意,这在作业的左侧不是必需的。

于 2016-07-28T15:53:06.610 回答
4

编辑您的 makefile 并在顶部插入以下内容:

export ARCHS = armv7 armv7s arm64
export TARGET = iphone:clang:7.0:7.0

此外,将Foundation框架与您的调整链接。

于 2014-01-18T05:30:36.947 回答
2

您需要通过添加 XXX_FRAMEWORKS = UIKit在Makefile中包含 UIKit 框架,其中 XXX 是您的项目名称

于 2014-11-12T21:29:24.257 回答
2

To fix the alert issue, you must include UIKit/UIKit.h (Sorry, I can't comment)

于 2014-03-29T16:31:25.017 回答
1

如果您使用的是 iOS 7,则必须挂钩正确的方法:try -(void)launchFromLocation:(int)location

因为它使用参数,所以您的代码应该如下所示:

-(void)launchFromLocation:(int)location {
    // your stuff
    %orig(location);
}
于 2014-03-25T11:01:26.960 回答
0

我会说更新你的标题。从rpetrich下载新集

于 2014-01-08T03:22:28.310 回答