Make package error

截图:


日志如下:
➜ wx make

Making all for tweak wx…
==> Preprocessing Tweak.x…
==> Compiling Tweak.x (armv7)…
Tweak.x:11:36: error: unexpected interface name ‘NSDictionary’: expected expression
NSDictionary *dic = MSHookIvar<NSDictionary *>(self,“m_dicBaseInfo”);
^
Tweak.x:11:25: error: use of undeclared identifier ‘MSHookIvar’
NSDictionary *dic = MSHookIvar<NSDictionary *>(self,“m_dicBaseInfo”);
^
Tweak.x:11:50: error: expected expression
NSDictionary *dic = MSHookIvar<NSDictionary *>(self,“m_dicBaseInfo”);
^
Tweak.x:11:52: error: expression result unused [-Werror,-Wunused-value]
NSDictionary *dic = MSHookIvar<NSDictionary *>(self,“m_dicBaseInfo”);
^~~~
Tweak.x:16:26: error: unexpected type name ‘id’: expected expression
id dele = MSHookIvar(self , “m_delegate”);
^
Tweak.x:16:15: error: use of undeclared identifier ‘MSHookIvar’
id dele = MSHookIvar(self , “m_delegate”);
^
Tweak.x:16:30: error: expression result unused [-Werror,-Wunused-value]
id dele = MSHookIvar(self , “m_delegate”);
^~~~
7 errors generated.
make[3]: *** [/Users/ruanyongwen/Desktop/wx/.theos/obj/debug/armv7/Tweak.x.0cd00fa3.o] Error 1
make[2]: *** [/Users/ruanyongwen/Desktop/wx/.theos/obj/debug/armv7/wx.dylib] Error 2
make[1]: *** [internal-library-all_] Error 2
make: *** [wx.all.tweak.variables] Error 2
我感觉是我的环境配置的有问题,但是我不清楚具体是哪里有问题

这是Tweak.x的代码

#include <substrate.h>
@interface WCRedEnvelopesReceiveHomeView
{
    NSDictionary *m_dicBaseInfo;
    id m_delegate;
}
@end
%hook WCRedEnvelopesReceiveHomeView
- (void)OnOpenRedEnvelopes {
        //%orig;
    NSDictionary *dic = MSHookIvar<NSDictionary *>(self,"m_dicBaseInfo");
    NSArray *keys = [dic allKeys];
    for (NSInteger index = 0 ; index < keys.count ; index++){
    NSLog(@"%@:%@",keys[index], [dic objectForKey:keys[index]]);
    }
    id dele = MSHookIvar<id>(self , "m_delegate");
    NSLog(@"m_delegate class:%@",dele);
}
%end

Tweak.x改成Tweak.xm

谢谢你啦,这问题卡了好几天了,按照你的答案已经可以了 :smiley:

可以把theos目录下的tar文件解包改一改

/opt/theos/vendor/templates/iphone_tweak.nic.tar

除了.x改成.xm,makefile也可以一起改了

DEBUG = 0

ARCHS = arm64 arm64e
TARGET = iphone:10.3
@@KILL_RULE@@

include @@THEOS@@/makefiles/common.mk

TWEAK_NAME = @@PROJECTNAME@@

@@PROJECTNAME@@_FILES = Tweak.xm
@@PROJECTNAME@@_CFLAGS = -fobjc-arc

include $(THEOS_MAKE_PATH)/tweak.mk

这样就不用每次都麻烦了。搞不懂为什么要默认.x