Attempting to compile MobileSubstrate addon - Undefined symbol

I went through this tutorial to create a MobileSubstrate addon. I could compile an example hook without errors.

But as soon as I add

#import <SpringBoard/SBAwayController.h>

      

in ExampleHookProtocol.h

and

SBAwayController *awayController = [SBAwayController sharedAwayController];

      

in ExampleHookLibrary.mm

(as the first line of the function __$ExampleHook_AppIcon_Launch

) I get the following error when I try make

(caused by the last change):

Undefined symbols:
  "_OBJC_CLASS_$_SBAwayController", referenced from:
    __objc_classrefs__DATA@0 in ExampleHookLibrary.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [ExampleHook.dylib] Error 1.

      

The header file for the SBAwayController is located in /var/toolchain/sys30/usr/include/SpringBoard

, like SBApplicationIcon.h

that used by the ExampleHook application.

I'm going to my iPod touch 2G.

Can anyone help me?

Thanks in advance,

Eric

+2


a source to share


2 answers


Since there is no reference to the link when compiling, you need to get the class at runtime, so add

Class $SBAwayController = objc_getClass("SBAwayController");

      

in the initializer and change



SBAwayController *awayController = [SBAwayController sharedAwayController];

      

to

SBAwayController *awayController = [$SBAwayController sharedAwayController];

      

+6


a source


You can also use:



SBAwayController *awayController = [objc_getClass("SBAwayController") sharedAwayController];

      

+1


a source







All Articles