[英]Xamarin forms iOS debug on iPhone from windows without cable
[英]iOS app debug without cable
是否可以登录到 iPhone 上的文件(或以某种方式获取控制台输出)以便稍后读取,或者直接从手机读取?
我需要调试一个使用有线连接附件设备的应用程序,因此它不能同时连接到 XCode。
您可以使用PonyDebugger 。
我经常使用它来调试网络和 CoreData 资源,但它也允许使用 PDLog 登录到控制台。
PonyDebugger 是一个远程调试工具集。 它是一个客户端库和网关服务器的组合,它使用浏览器上的 Chrome 开发者工具来调试应用程序的网络流量和托管对象上下文。
一些建议:
[debugger connectToURL:[NSURL URLWithString:@"ws://192.168.0.12:9000/device"]];
很遗憾苹果没有为Xcode提供WiFi调试,但是对于你的问题,答案是肯定的,你绝对可以将NSLog重定向到一个日志文件,你可以试试这个方法:
// this will redirect all NSLog in your project, add it to PCH file.
#define NSLog(args...) writeLog(__PRETTY_FUNCTION__, __LINE__, args)
void writeLog(const char *function, int lineNumber, NSString *format, ...) {
// basic log content.
va_list ap;
va_start (ap, format);
NSString *msg = [[NSString alloc] initWithFormat:format arguments:ap];
va_end (ap);
// add function name, and line number.
NSString *log = [NSString stringWithFormat:@"%s line %d $ %@", function, lineNumber, msg];
// add your own code to write `log` into a text file.
....
}
注意:如果您使用的一些库也将日志写入控制台,则此宏不会将这些日志重定向到您的日志文件,它只会在您自己的源文件中与NSLog
一起使用。
据我所知,这是不可能的。
您最终可以使用免费且优秀的解决方案,例如bugfender ,它允许您远程获取 NSLog 记录的数据。 这可以帮助你。
Kevin Xi 的做法是可以的。 您还可以使用 AppDelegate 的 didFinishLaunchingWithOptions 方法中的以下代码将 NSLog 输出重定向到文件:
NSArray *allPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [allPaths objectAtIndex:0];
NSString *pathForLog = [documentsDirectory stringByAppendingPathComponent:@"log.txt"];
freopen([pathForLog cStringUsingEncoding:NSASCIIStringEncoding],"a+", stderr);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.