如何在iOS AdHoc版本上调试Firebase

时间:2017-05-03 08:23:24

标签: xcode debugging firebase firebase-analytics adhoc

调试Firebase的唯一方法是在启动时传递的参数上传递-FIRAnalyticsDebugEnabled

它在调试模式下工作,我的iOS设备已连接,但我想部署一个AdHoc版本,所以QA可以在没有Xcode的情况下测试它。

但是当Xcode归档构建时,似乎没有在启动时传递参数。

任何解决方案?谢谢。

4 个答案:

答案 0 :(得分:22)

我找到了hack解决方案,在您的应用程序中尝试:didFinishLaunchingWithOptions:或覆盖AppDelegate的init:

目标-C:

NSMutableArray *newArguments = [NSMutableArray arrayWithArray:[[NSProcessInfo processInfo] arguments]];
[newArguments addObject:@"-FIRDebugEnabled"];
[[NSProcessInfo processInfo] setValue:[newArguments copy] forKey:@"arguments"];

夫特:

var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")

答案 1 :(得分:1)

仅在最高级的答案中添加一些内容: 我会做这样的事情

#if DEBUG
     var newArguments = ProcessInfo.processInfo.arguments
        newArguments.append("-FIRDebugEnabled")
        ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
#endif

使其保持调试状态。这需要您在构建设置的“其他Swift标志”中设置-DDEBUG。 (当然,您需要为此设置Debug值。

然后记得在初始化Firebase之前放入代码段:-)

答案 2 :(得分:0)

目前无法在AdHoc构建或发布版本中打开调试模式,这是故意的。 DebugView仅用于开发。构建应用程序后,您只能检查实际流量,即运行后2-4小时。

答案 3 :(得分:0)

除了上述建议

  • 为每种构建模式(即:Debug,Adhoc和Release)添加 xcconfig文件https://www.appcoda.com/xcconfig-guide
  • 添加所有配置文件FIREBASE_DEBUG_ENABLED = YESNO(即,YESRelease以外的所有地方)
  • 将键为FirebaseDebugEnabled和字符串值为$(FIREBASE_DEBUG_ENABLED)
  • 的条目添加到您的 Info.plist 文件中
  • 在您的AppDelegate.m的{​​{1}}方法中,添加以下语句
  

NSString * plistPath = [[NSBundle mainBundle] pathForResource:@“ Info”   ofType:@“ plist”]; NSDictionary * plistConfig = [[NSDictionary分配]   initWithContentsOfFile:plistPath];

     

// Firebase BOOL isFirebaseDebugEnabled = [[plistConfig   valueForKey:@“ FirebaseDebugEnabled”] boolValue];

     

if(isFirebaseDebugEnabled){       NSLog(@“启用Firebase调试。”);       NSMutableArray * newArguments = [NSMutableArray arrayWithArray:[[NSProcessInfo processInfo] arguments]];       [newArguments addObject:@“-FIRAnalyticsDebugEnabled”];       [newArguments addObject:@“-FIRDebugEnabled”];       [[NSProcessInfo processInfo] setValue:[newArguments复制] forKey:@“ arguments”]; }

     

[FIRApp配置];

您可以在目标方案的didFinishLaunchingWithOptions部分中选择要使用的构建配置(默认值:Run)来构建应用,然后尝试在{{ 1}}和Debug模式。

相关问题