Question

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.

Was it helpful?

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

OTHER TIPS

Error messages seem to be non-helpful--at first anyway. But they usually are informative but it takes some studying to learn how to interpret the. The worst for most people are linker messages but they are also informative, it just takes some studying.

Let's look at them:

double threshold = [SBLockScreenNotificationScrollView scrollThresholdForPasscodeScroll];

Receiver 'SBLockScreenNotificationScrollView' for class message is a forward declaration

There is only a forward declaration, probably @SBLockScreenNotificationScrollView The actual declaration of the class SBLockScreenNotificationScrollView and it's method scrollThresholdForPasscodeScroll need to be seen by the class (.m file).

No known class method for selector 'scrollThresholdForPasscodeScroll'

The method scrollThresholdForPasscodeScroll is not known. This follows from the previous error message that implied that there was no declaration.

Initializing 'double' with an expression of incompatible type 'id'

This one is a little harder. Since the method declaration of scrollThresholdForPasscodeScroll was not seen the compiler makes an assumption that the return type is an id yet it is assigned to a double.

So, it seems they all come down to the declaration not being seen and that implies that perhaps the header file (.h) was not imported. Check that it is imported correctly or add the import.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top