Ant*_*ond 13 debugging xcode adhoc firebase firebase-analytics
调试Firebase的唯一方法是-FIRAnalyticsDebugEnabled传递启动时传递的参数.
它在调试模式下工作,我的iOS设备已连接,但我想部署一个AdHoc版本,所以QA可以在没有Xcode的情况下测试它.
但是当Xcode归档构建时,似乎没有在启动时传递参数.
有解决方案吗 谢谢.
小智 31
我找到了hack解决方案,在你的应用程序中尝试:didFinishLaunchingWithOptions:或覆盖AppDelegate的init:
Objective-C的:
NSMutableArray *newArguments = [NSMutableArray arrayWithArray:[[NSProcessInfo processInfo] arguments]];
[newArguments addObject:@"-FIRDebugEnabled"];
[[NSProcessInfo processInfo] setValue:[newArguments copy] forKey:@"arguments"];
Run Code Online (Sandbox Code Playgroud)
迅速:
var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
Run Code Online (Sandbox Code Playgroud)
小智 7
In addition to proposition above:
FIREBASE_DEBUG_ENABLED = YES or NO (ie: YES everywhere except Release)FirebaseDebugEnabled, and string value: $(FIREBASE_DEBUG_ENABLED)AppDelegate.m, in didFinishLaunchingWithOptions method, add the following statement: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];
Run Code Online (Sandbox Code Playgroud)
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")
}
}
Run Code Online (Sandbox Code Playgroud)
您可以在目标方案中选择构建您的应用程序,在Run部分中,您要使用的构建配置(默认值:)Debug,因此,尝试在Adhoc和Release模式下运行您的应用程序。
只是对最高的答案进行了一些补充:我会做这样的事情
#if DEBUG
var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
#endif
Run Code Online (Sandbox Code Playgroud)
以保持调试。这需要您-DDEBUG在 Build Settings 的“Other Swift Flags”中进行设置。(当然,您需要为 Debug 值设置此项。
然后记得在初始化 Firebase 之前放置代码片段 :-)
| 归档时间: |
|
| 查看次数: |
2764 次 |
| 最近记录: |