需求:解决make时候NSLog方法undeclared错误
**日志:
make
==> 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 readingcrack…
==> Compiling src/PFLListenBookVC_test.xm (arm64)…
src/PFLListenBookVC_test.xm:4:181: error: use of undeclared identifier ‘NSLog’
…__unused self, SEL __unused _cmd, _Bool hasReport) { NSLog(@“-[<PFLList…
^
src/PFLListenBookVC_test.xm:5:160: error: use of undeclared identifier ‘NSLog’
…_LOGOS_SELF_CONST __unused self, SEL __unused _cmd) { NSLog(@”-[<PFLList…
Making all for tweak readingcrack…
==> Preprocessing Tweak.x…
==> Preprocessing Tweak.x…
==> Preprocessing Tweak.x…
==> Compiling Tweak.x (arm64)…
Tweak.x:15:2: error: implicitly declaring library function ‘NSLog’ with type ‘void (id, …)’ [-Werror,-Wimplicit-function-declaration]
NSLog(@“-[<ClassName: %p> messageName:%d]”, self, argument);
^
Tweak.x:15:2: note: include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for ‘NSLog’
Tweak.x:18:60: error: incompatible pointer to integer conversion passing ‘void *’ to parameter of type ‘int’ [-Werror,-Wint-conversion]
_logos_orig$_ungrouped$ClassName$messageName$(self, _cmd, nil);
^~~
/Applications/Dev/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/include/objc/objc.h:108:16: note: expanded from macro ‘nil’
/* How to Hook with Logos
Hooks are written with syntax similar to that of an Objective-C @implementation.
You don’t need to #include <substrate.h>, it will be done automatically, as will
the generation of a class list and an automatic constructor.
*/
%hook ClassName
// Hooking a class method
(id)sharedInstance {
return %orig;
}
// Hooking an instance method with an argument.
(void)messageName:(int)argument {
%log; // Write a message about this call, including its class, name and arguments, to the system log.
%orig; // Call through to the original function with its original arguments.
%orig(nil); // Call through to the original function with a custom argument.
// If you use %orig(), you MUST supply all arguments (except for self and _cmd, the automatically generated ones.)
}
// Hooking an instance method with no arguments.
(id)noArguments {
%log;
id awesome = %orig;
[awesome doSomethingElse];
return awesome;
}
// Always make sure you clean up after yourself; Not doing so could have grave consequences!
%end