『導言』
親吶,你有木有升級xcode8
?有木有遇到這樣的輸出,老長了,怎么辦?
-
分析:
升級xcode8
后,屏蔽后臺的多余
的輸出log
輸出:
objc[2126]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x12ce244c) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x12b23b78). One of the two will be used. Which one is undefined.
2017-04-05 11:38:20.033821 DeliciousFoodDemo[2126:87760] [] nw_host_stats_add_src recv too small, received 24, expected 28
2017-04-05 11:38:20.039139 DeliciousFoodDemo[2126:87760] [] ____nwlog_simulate_crash_inner_block_invoke dlopen CrashReporterSupport failed
2017-04-05 11:38:20.039711 DeliciousFoodDemo[2126:87760] [] __nwlog_err_simulate_crash simulate crash failed "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2017-04-05 11:38:20.041064 DeliciousFoodDemo[2126:87760] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
[i386] libnetcore-856.30.16
0 libsystem_network.dylib 0x032f414d __nw_create_backtrace_string + 123
1 libnetwork.dylib 0x043fa7a6 nw_socket_add_input_handler + 3588
2 libnetwork.dylib 0x043d56fe nw_endpoint_flow_attach_protocols + 4199
3 libnetwork.dylib 0x043d457a nw_endpoint_flow_setup_socket + 581
4 libnetwork.dylib 0x043d31ed -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2545
5 libnetwork.dylib 0x043f0cf0 nw_endpoint_handler_path_change + 2835
6 libnetwork.dylib 0x043f00f6 nw_endpoint_handler_start + 589
7 libnetwork.dylib 0x044098c0 nw_endpoint_resolver_start_next_child + 2634
8 libdispatch.dylib 0x03092396 _dispatch_call_block_and_release + 15
9 libdispatch.dylib 0x030bdcc3 _dispatch_client_callout + 14
10 libdispatch.dylib 0x0309a3ae _dispatch_queue_serial_drain + 1619
11 libdispatch.dylib 0x0309abc2 _dispatch_queue_invoke + 1109
12 libdispatch.dylib 0x0309d5e4 _dispatch_root_queue_drain + 470
13 libdispatch.dylib 0x0309d3a6 _dispatch_worker_thread3 + 143
14 libsystem_pthread.dylib 0x0350e25c _pthread_wqthread + 1050
15 libsystem_pthread.dylib 0x0350bf56 start_wqthread + 34
解決方法
-
首先,找到
Environment Variable
- 找到在Xcode的菜單欄,依次進入:
【product
】-【scheme】
-【Edit Scheme】
-【Run】
-【Argument】
-【Environment Variable
】</br>
- 找到在Xcode的菜單欄,依次進入:
-
或 快捷鍵操作:
快捷鍵【 shift】
+【command】
+【< 】
圖.添加設置 -
然后,點擊
+
添加進行設置
key | value |
---|---|
OS_ACTIVITY_MODE |
disable |
圖.設置
動態教程.gif
-
補充:
-
遺留問題:還會出現,屬于
正常現象
Class PLBuildVersion is implemented2017-04-05 11:05:47.616 DeliciousFoodDemo[2090:68216] http://api.2meiwei.com/v1/index/index/
objc[2090]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x18c0b44c) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x18a4cb78). One of the two will be used. Which one is undefined.
2017-04-05 11:05:47.778 DeliciousFoodDemo[2090:68216] 0
圖.xcode8遺留問題.png
問題分析:
意思是PhotoLibraryServices.framework
和AssetsLibraryServices.framework
產生了沖突,系統不知道用哪個
Class PLBuildVersion在
框架AssetsLibraryServices
和框架PhotoLibraryServices
里都有定義。在Objective-C里Class名是唯一
。兩個同名的Class,Xcode會選擇其中一個Class來執行。PLBuildVersion
在這兩個框架里都是一樣的,不影響
實際運行。-
在xcode8中,屏蔽了一些奇怪的輸出之后,又發現了一個。具體啥原因還不是太清楚。但是可以解決這個問題,讓其停止打印這個信息。
在
info.plist
中,添加兩個鍵值對:
|序號|對象|key|value|
|-------|--------|-------|
|1|針對photo
|Privacy - Photo Library Usage Description
| $(PRODUCT_NAME) photo use
//(解釋對相冊的使用)|
|2|針對camera
|Privacy - Camera Usage Description
|$(PRODUCT_NAME) camera use
//(解釋對相機的使用)|
這個方法僅僅解決了photo
方面的,好像別的功能(加載WebView
)也會有類似的報錯。
主要是因為iOS10在用戶的隱私方面的改動。
并不影響程序工作,但是還沒有找到完全避免的方法!
更新到Xcode新版本之后,這個打印已經沒有了。比如:使用的是Xcode 8.2.1
。沒有這個打印問題!
圖.plist設置.png