书上105页的例子,关于SBScreenShotter的用法

书上105页那个测试函数.
代码为:

%hook SpringBoard
- (void) menuButtonDown:(id)down
{
%orig;
SBScreenShotter *shotter = %c(SBScreenShotter) sharedInstance];
[shotter saveScreenshot];


}
%end

对应的makefile为

THEOS_DEVICE_IP = 192.168.1.252
ARCHS = armv7 armv7s arm64
TARGET = iphone:8.1:5.0
include theos/makefiles/common.mk

TWEAK_NAME = hoolSprpingB
hoolSprpingB_FILES = Tweak.xm

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
	install.exec "killall -9 SpringBoard"

在工程目录下make,提示如下错误.

Making all for tweak hoolSprpingB...
 Preprocessing Tweak.xm...
 Compiling Tweak.xm...
Tweak.xm:5:74: error: class method '+sharedInstance' not found (return type
      defaults to 'id') -Werror,-Wobjc-method-access]
  ...= [_logos_static_class_lookup$SBScreenShotter() sharedInstance];
                                                     ^~~~~~~~~~~~~~
Tweak.xm:6:10: error: instance method '-saveScreenshot' not found (return type
      defaults to 'id') -Werror,-Wobjc-method-access]
[shotter saveScreenshot];
         ^~~~~~~~~~~~~~
Tweak.xm:3:8: note: receiver is instance of class declared here
@class SBScreenShotter; @class SpringBoard; 
       ^
2 errors generated.
make[2]: *** [obj/Tweak.xm.e6ba7d32.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [hoolSprpingB.all.tweak.variables] Error 2

求大神解答.

好吧 刚才用谷歌搜索发现有人问过了。。

怎么删不了帖子 在哪里删除//

删掉干嘛,留给其他人来参考吧,我今天也遇到了,参考了这个帖子狗神的指示:http://bbs.iosre.com/t/theos-iosopendev/313/4 解决了问题。

我是在Twaek.xm上添加如下代码解决的
@interface SBScreenshotter: NSObject
{
BOOL _writingScreenshot;
unsigned int _screenshotWriteCount;
}

  • (id)sharedInstance;
  • (void)saveScreenshot: (BOOL)arg1;
    @end

只用加

@interface SBScreenShotter: NSObject

@end

就可以了