user6632515
user6632515

Reputation: 203

Mobile Substrate: Undefined symbols for architecture armv7: "_main"

I am writing an tweak that injects code in an application.

To do it, I followed the guide in this SO question: iOS - Add "objects" to existing app (jailbroken)

I tried it but am getting this error when building:

Undefined symbols for architecture armv7:   "_main"

Code:

#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
    );
}

Makefile:

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

Thanks

Upvotes: 1

Views: 309

Answers (1)

user6632515
user6632515

Reputation: 203

Fixed by replacing the full Makefile with

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"

Upvotes: 1

Related Questions