无法在 Swift 中使用 Xcode 9 消除 Firebase Analytics 线程警告
Unable to eliminate Firebase Analytics Thread warnings using Xcode 9 in Swift
在使用现有项目移至 Xcode9 后,我一直收到来自 Main Thread Checker 的警告,关于一个名为 FIRAnalyticsQueue
的队列。
我发现这个 MTC 是一个很棒的功能,因为我已经用它解决了很多线程问题,但不幸的是我无法消除与 Firebase 配置有关的问题。
我在 AppDelegate
didFinishLaunchingWithOptions
函数中使用的代码如下:
if FIRApp.defaultApp() == nil {
FIRApp.configure()
}
以及我在评估上面的代码后收到的日志:
2017-10-05 16:14:34.965 PonySugarCandyApp[17721] <Error> [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add [FIRApp configure] to your application initialization.
2017-10-05 16:14:45.283 PonySugarCandyApp[17721] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3700000 started
2017-10-05 16:14:52.139 PonySugarCandyApp[17721] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication delegate]
PID: 17721, TID: 1309471, Thread name: (none), Queue name: FIRAnalyticsQueue, QoS: 9
Backtrace:
4 PonySugarCandyApp 0x000000010c5fe721 __38+[FIRAnalytics createAppDelegateProxy]_block_invoke + 55
5 libdispatch.dylib 0x000000011337143c _dispatch_client_callout + 8
6 libdispatch.dylib 0x00000001133729c7 dispatch_once_f + 297
7 PonySugarCandyApp 0x000000010c5fd519 __47+[FIRAnalytics startWithConfiguration:options:]_block_invoke_2 + 101
8 libdispatch.dylib 0x00000001133703f7 _dispatch_call_block_and_release + 12
9 libdispatch.dylib 0x000000011337143c _dispatch_client_callout + 8
10 libdispatch.dylib 0x000000011337995b _dispatch_queue_serial_drain + 1162
11 libdispatch.dylib 0x000000011337a2df _dispatch_queue_invoke + 336
12 libdispatch.dylib 0x000000011337d1f9 _dispatch_root_queue_drain + 772
13 libdispatch.dylib 0x000000011337ce97 _dispatch_worker_thread3 + 132
14 libsystem_pthread.dylib 0x00000001138345a2 _pthread_wqthread + 1299
15 libsystem_pthread.dylib 0x000000011383407d start_wqthread + 13
(Recorded stack frame)
这已在最新版本的 Firebase 中修复。执行 pod update
升级到 Firebase 4.3.0。 https://github.com/firebase/firebase-ios-sdk/issues/69.
中有关此问题和修复的更多详细信息
我相信转到你的项目名称并单击编辑方案,你可以进入你的环境变量并添加:
Name: "OS_ACTIVITY_MODE"
Value: "disable"
这应该会阻止 firebase 在 运行 您的应用程序时将一堆文本打印到您的控制台。
我遇到了最新版本的 Firebase(截至 2017 年 19 月 12 日)的问题,此修复工作正常。
在使用现有项目移至 Xcode9 后,我一直收到来自 Main Thread Checker 的警告,关于一个名为 FIRAnalyticsQueue
的队列。
我发现这个 MTC 是一个很棒的功能,因为我已经用它解决了很多线程问题,但不幸的是我无法消除与 Firebase 配置有关的问题。
我在 AppDelegate
didFinishLaunchingWithOptions
函数中使用的代码如下:
if FIRApp.defaultApp() == nil {
FIRApp.configure()
}
以及我在评估上面的代码后收到的日志:
2017-10-05 16:14:34.965 PonySugarCandyApp[17721] <Error> [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add [FIRApp configure] to your application initialization.
2017-10-05 16:14:45.283 PonySugarCandyApp[17721] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3700000 started
2017-10-05 16:14:52.139 PonySugarCandyApp[17721] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication delegate]
PID: 17721, TID: 1309471, Thread name: (none), Queue name: FIRAnalyticsQueue, QoS: 9
Backtrace:
4 PonySugarCandyApp 0x000000010c5fe721 __38+[FIRAnalytics createAppDelegateProxy]_block_invoke + 55
5 libdispatch.dylib 0x000000011337143c _dispatch_client_callout + 8
6 libdispatch.dylib 0x00000001133729c7 dispatch_once_f + 297
7 PonySugarCandyApp 0x000000010c5fd519 __47+[FIRAnalytics startWithConfiguration:options:]_block_invoke_2 + 101
8 libdispatch.dylib 0x00000001133703f7 _dispatch_call_block_and_release + 12
9 libdispatch.dylib 0x000000011337143c _dispatch_client_callout + 8
10 libdispatch.dylib 0x000000011337995b _dispatch_queue_serial_drain + 1162
11 libdispatch.dylib 0x000000011337a2df _dispatch_queue_invoke + 336
12 libdispatch.dylib 0x000000011337d1f9 _dispatch_root_queue_drain + 772
13 libdispatch.dylib 0x000000011337ce97 _dispatch_worker_thread3 + 132
14 libsystem_pthread.dylib 0x00000001138345a2 _pthread_wqthread + 1299
15 libsystem_pthread.dylib 0x000000011383407d start_wqthread + 13
(Recorded stack frame)
这已在最新版本的 Firebase 中修复。执行 pod update
升级到 Firebase 4.3.0。 https://github.com/firebase/firebase-ios-sdk/issues/69.
我相信转到你的项目名称并单击编辑方案,你可以进入你的环境变量并添加:
Name: "OS_ACTIVITY_MODE"
Value: "disable"
这应该会阻止 firebase 在 运行 您的应用程序时将一堆文本打印到您的控制台。
我遇到了最新版本的 Firebase(截至 2017 年 19 月 12 日)的问题,此修复工作正常。