调试Firebase的唯一方法是在启动时通过参数-FIRAnalyticsDebugEnabled
传递。
我的iOS设备连接后,在调试模式下它可以工作,但我想部署一个AdHoc版本,以便QA可以在没有Xcode的情况下测试它。
但是似乎当Xcode存档构建时,参数不会在启动时传递。
有什么解决方案吗?谢谢。
调试Firebase的唯一方法是在启动时通过参数-FIRAnalyticsDebugEnabled
传递。
我的iOS设备连接后,在调试模式下它可以工作,但我想部署一个AdHoc版本,以便QA可以在没有Xcode的情况下测试它。
但是似乎当Xcode存档构建时,参数不会在启动时传递。
有什么解决方案吗?谢谢。
我找到了一种非正规的解决方案,可以在你的application:didFinishLaunchingWithOptions:中尝试它,或者重写AppDelegate的init方法:
Objective-C:
NSMutableArray *newArguments = [NSMutableArray arrayWithArray:[[NSProcessInfo processInfo] arguments]];
[newArguments addObject:@"-FIRDebugEnabled"];
[[NSProcessInfo processInfo] setValue:[newArguments copy] forKey:@"arguments"];
Swift:
-->Swift编程语言:
var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
只是对最新回答的一些补充: 我会做类似于这样的事情
#if DEBUG
var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
#endif
保持其可调试性。需要在构建设置中的"其他Swift标志"中设置-DDEBUG
(当然,你需要将其设置为Debug值)。
然后记得在初始化Firebase之前放置代码片段:-)
除了上面提到的建议之外:
FIREBASE_DEBUG_ENABLED = YES
或NO
(即Release
以外处处都是YES
)FirebaseDebugEnabled
,值为$(FIREBASE_DEBUG_ENABLED)
的条目AppDelegate.m
文件中,在didFinishLaunchingWithOptions
方法中添加以下语句:Objective-C
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSDictionary *plistConfig = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
// Firebase
BOOL isFirebaseDebugEnabled = [[plistConfig valueForKey:@"FirebaseDebugEnabled"] boolValue];
if (isFirebaseDebugEnabled) {
NSLog(@"Firebase debug enabled.");
NSMutableArray *newArguments = [NSMutableArray arrayWithArray:[[NSProcessInfo processInfo] arguments]];
[newArguments addObject:@"-FIRAnalyticsDebugEnabled"];
[newArguments addObject:@"-FIRDebugEnabled"];
[[NSProcessInfo processInfo] setValue:[newArguments copy] forKey:@"arguments"];
}
[FIRApp configure];
Swift 4.2
if let path = Bundle.main.path(forResource: "Info", ofType: "plist"),
let plist = FileManager.default.contents(atPath: path),
let preferences = try? PropertyListSerialization.propertyList(from: plist, options: .mutableContainersAndLeaves, format: nil) as? [String:AnyObject],
let isFirebaseDebugEnabled = preferences["FirebaseDebugEnabled"] as? Bool
{
if isFirebaseDebugEnabled {
var args = ProcessInfo.processInfo.arguments
args.append("-FIRAnalyticsDebugEnabled")
args.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(args, forKey: "arguments")
}
}
您可以在目标方案中选择构建配置文件,即在 运行
部分中选择您想要使用的构建配置文件 (默认为 调试(Debug)
),并尝试以 Adhoc
和 发布(Release)
模式运行您的应用程序。
目前在AdHoc版本或发布版本中没有开启调试模式的方法,这是有意为之的。DebugView仅用于开发。一旦您构建了应用程序,您只能检查实际流量,即在运行后2-4小时内。
application:didStartWithOptions:
中早期放置它,这样可以正常工作。 - xZenon