objective-cjailbreakiphone-privateapicydia-substratelogos

unable to find SBLockScreenNotificationScrollView.h file in Springboard API


I'm working on an cydia substrate tweak and I have this line of code:

double threshold = [SBLockScreenNotificationScrollView scrollThresholdForPasscodeScroll];

When I try to compile I'm getting these errors and warnings for the line.

enter image description here

I've imported <Springboard/Springboard.h> in my file and it's coming from /opt/theos/include. I've also tried importing <SBLockScreenNotificationScrollView.h>, but it's unable to find the file. I'm a bit lost here and any help is appreciated. Thanks.

Edit: I've tried using these headers instead, but they give me a whole bunch of errors, too many for the compiler to list.


Solution

  • The root cause here is that the API you want to use is a Private API. If you want to include a file such as SBLockScreenNotificationScrollView.h, you'll need to acquire or generate that header file, and put it into your project manually. That file doesn't get automatically delivered with Theos/Logos, or the iOS SDK.

    Probably the easiest thing to do is to run class-dump, or class-dump-z, to reverse-engineer that header file. The class dump should be run on the SpringBoard executable itself. SpringBoard is an app (not a framework), that lives on the iPhone at /System/Library/CoreServices/SpringBoard.app/SpringBoard. So, if your device is jailbroken, and you have openssh installed, you can ssh into the device (or use scp) to transfer the executable to your Mac:

    scp root@iphone-ip-address:/System/Library/CoreServices/SpringBoard.app/SpringBoard .
    

    Then, run class dump on the executable:

    class-dump-z -H SpringBoard
    

    and you'll get a huge set of header files in the current directory, including SBLockScreenNotificationScrollView.h.

    You'll probably then notice that your header depends on another header, which depends on another header. If you try to build, you'll often encounter build errors that are frustrating to chase down. My recommendation would be to cut out all the stuff you don't need from the header that contains the private methods you want. Those private headers, when included in your project, don't need to be a complete specification of the private classes (e.g. the SBLockScreenNotificationScrollView class). They just need to contain a minimal description of the interfaces you're trying to call, to satisfy the compiler.

    Example

    This pruned header would probably be sufficient for you (noting what I've commented out):

    //#import "UIGestureRecognizerDelegate.h"
    //#import <XXUnknownSuperclass.h> // Unknown library
    
    //@class SBLockScreenNotificationCell;
    
    @interface SBLockScreenNotificationScrollView /* : XXUnknownSuperclass <UIGestureRecognizerDelegate> */ {
    //        SBLockScreenNotificationCell* _associatedCell;
    }
    //@property(assign, nonatomic) SBLockScreenNotificationCell* associatedCell;
    +(float)scrollThresholdForPasscodeScroll;
    @end
    

    Note: after that, if you're getting linker errors, there's probably more you'll need to do. I recommend posting another question on theos/logos linker errors, show the error output, and someone may be able to help you. That way, we keep each question narrow and specific. Thanks!

    References

    iPhone private API compiling