1

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.

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
  • 2
    `id` is a generalized object pointer, while `double` is a "scalar". Never the twain shall meet. But in this case the more significant error (and cause of the first) is that the compiler hasn't a clue what SBLockScreenNotificationScrollView is, presumably because you haven't included the .h file. – Hot Licks Mar 01 '14 at 21:53
  • Maybe you used a forward class declaration in your .h file, and didn't #include it in your .m file??? – Merlevede Mar 01 '14 at 21:56
  • I guess what I'm trying to figure out is why I can't find the SBLockScreenNotificationScrollView.h file. The title is a bit misleading. I'll fix that. – Connor Pearson Mar 01 '14 at 21:57

2 Answers2

1

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

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207
0

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.

zaph
  • 111,848
  • 21
  • 189
  • 228
  • Thanks for the answer Zaph, but what I'm trying to figure out is why I'm unable to import the SBLockScreenNotificationScrollView file or why it isn't included. – Connor Pearson Mar 01 '14 at 22:24
  • @Nate I've read your answer and I'm looking into trying to dump the headers myself. In the private frameworks directory though, the springboard framework isn't included – Connor Pearson Mar 02 '14 at 00:19
  • @Nate ok so I've dumped the springboard headers and included them but now I'm getting errors when trying run. it seems every import in the headers is broken – Connor Pearson Mar 02 '14 at 00:43
  • @Nate now I'm getting a linker error. How can I link to springboard since it is an app? – Connor Pearson Mar 02 '14 at 03:37
  • @Nate I understand. thanks for your help. if you'll post an answer explaining what you said in the commments, I'll accept it – Connor Pearson Mar 02 '14 at 18:25