Tweak安装正确;我试图记录指定钩子的每个方法调用的跟踪。
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
@interface logTool: NSObject
+ (void)logDataFromNSString: (NSString *)logContent;
@end
@implementation logTool
+ (void)logDataFromNSString: (NSString *)logContent
{
NSFileHandle *file;
NSData *data;
file = [NSFileHandle fileHandleForUpdatingAtPath: @"/tmp/filelog.txt"];
[file seekToEndOfFile];
logContent = [logContent stringByAppendingString:@"\n------------\n"];
data = [logContent dataUsingEncoding:NSUTF8StringEncoding];
[file writeData: data];
[file closeFile];
}
@end
%hook IGAPIRequestBuilder
+ (id)builderWithHTTPMethod:(unsigned long long)arg1 format:(id)arg2
{
[logTool logDataFromNSString:@">>>> BEGIN - [IGAPIRequestBuilder builderWithHTTPMethod]"];
id ret = %orig;[logTool logDataFromNSString:[NSString stringWithFormat:@"ret value: %@", ret]];
[logTool logDataFromNSString:@"<<<< END - [IGAPIRequestBuilder builderWithHTTPMethod]"];
return ret;
}
%end
^到目前为止,这是我的尝试;但我的应用程序似乎正在崩溃我打开应用程序的妈妈。当我摆脱%hook IGAPIRequestBuilder中的所有内容时,它似乎再次正常工作。
我目前在ios 10.2上。代码编译得很好。我无法想出调试问题的方法,因此它会引导我们采取更具体的方式,如果它太过分,就会道歉。
https://pastebin.com/7vYQ40e0 - 这是崩溃报告