小白,首次编译tweak工程,提示如下报错信息
==> Notice: Build may be slow as Theos isn’t using all available CPU cores on this computer. Consider upgrading GNU Make: Parallel Building · theos/theos Wiki · GitHub
Making all for tweak gd…
==> Preprocessing Tweak.xm…
==> Compiling Tweak.xm (armv7)…
Tweak.xm:23:136: error: declaration of ‘NSString’ must be imported from module ‘ObjectiveC.NSObject’ before it is required
static id (*_logos_meta_orig$_ungrouped$NSURLProtocol$propertyForKey$inRequest$)(_LOGOS_SELF_TYPE_NORMAL Class _LOGOS_SELF_CONST, SEL, NSString *, id); static id _logos_m…
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/include/objc/./NSObject.h:13:8: note: previous declaration is here
@class NSString, NSMethodSignature, NSInvocation;
^
Tweak.xm:4:9: error: receiver type ‘NSString’ for instance message is a forward declaration
if([key isEqualToString:@“networkRedirectCount”])
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/include/objc/./NSObject.h:13:8: note: forward declaration of class here
@class NSString, NSMethodSignature, NSInvocation;
^
Tweak.xm:6:16: error: definition of class NSNumber must be available to use Objective-C numeric literals
return @1;
^
3 errors generated.
xcode版本是:12.4
macos版本:10.15.7
Tweak.mk代码如下:
%hook NSURLProtocol
+(id)propertyForKey:(NSString *)key inRequest:(id)inRequest
{
if([key isEqualToString:@“networkRedirectCount”])
{
return @1;
}
return %orig;
}
%end
Makefile文件如下:
THEOS_DEVICE_IP = 172.18.253.190
THEOS_DEVICE_PORT = 22
TARGET := iphone:clang:latest:7.0
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = gd
gd_FILES = Tweak.xm
gd_CFLAGS = -fobjc-arc
include $(THEOS_MAKE_PATH)/tweak.mk
恳请大佬解答,不胜感激