【问题标题】:Mobile Substrate: Undefined symbols for architecture armv7: "_main"移动基板:架构 armv7 的未定义符号:“_main”
【发布时间】:2017-08-12 03:24:49
【问题描述】:

我正在编写一个在应用程序中注入代码的调整。

为此,我遵循了这个 SO 问题中的指南:iOS - Add "objects" to existing app (jailbroken)

我试过了,但是在构建时遇到了这个错误:

Undefined symbols for architecture armv7:   "_main"

代码:

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <objc/runtime.h>
#import <substrate.h>

static IMP __original_init; // A

id __modified_init(id __self, SEL __cmd, CGRect frame) // B
{
    __self = __original_init(__self, __cmd, frame); // C

    // D
    UIButton *newButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [newButton setTitle:@"Please, laat het werken!" forState:UIControlStateNormal];
    newButton.frame = CGRectMake(0, 0, 100, 40);
    [__self addSubview:newButton];

    return __self;
}

// E
__attribute__((constructor))
void init()
{
    MSHookMessageEx(
        objc_getClass("YTHUDMessageView"),
        @selector(initWithFrame:),
        (IMP)__modified_init,
        &__original_init
    );
}

生成文件:

include $(THEOS)/makefiles/common.mk

APPLICATION_NAME = test8
test8_FILES = test.m 
test8_FRAMEWORKS = UIKit CoreGraphics
test8_LIBRARIES = substrate

include $(THEOS_MAKE_PATH)/application.mk

after-install::
    install.exec "killall \"test8\"" || true

谢谢

【问题讨论】:

    标签: ios objective-c cydia


    【解决方案1】:

    通过将完整的 Makefile 替换为修复

    include $(THEOS)/makefiles/common.mk
    
    TWEAK_NAME = test8
    test8_FILES = test.m 
    
    include $(THEOS_MAKE_PATH)/tweak.mk
    
    after-install::
        install.exec "killall -9 SpringBoard"
    

    【讨论】:

      猜你喜欢
      • 2016-04-29
      • 2011-09-19
      • 1970-01-01
      • 1970-01-01
      • 2013-03-16
      • 2012-06-11
      • 1970-01-01
      相关资源
      最近更新 更多