尝试从 URL 获取数据并获取控制台警告

Trying to get Data from the URL and get console warnings

我在 Xcode 10 beta 和 iOS 12 工作。下面是看起来不错的代码片段,并且做了它应该做的事情:

DispatchQueue.global().async {
    guard let imageUrl = URL(string: course.imageUrl!) else { return }
    guard let imageData = try? Data(contentsOf: imageUrl) else { return }
    DispatchQueue.main.async {
        cell.courseImage.image = UIImage(data: imageData)
    }
}

下一行:

guard let imageData = try? Data(contentsOf: imageUrl) else { return }

在模拟器中导致 iOS 12 控制台中的下一个输出:

2018-09-07 12:02:25.045814+0500 Networking[69467:3561679] [BoringSSL] boringssl_session_errorlog(224) [C1.1:2][0x7fccdf534820] [boringssl_session_read] SSL_ERROR_SSL(1): operation failed within the library 2018-09-07 12:02:25.045951+0500 Networking[69467:3561679] [BoringSSL] boringssl_session_handshake_error_print(205) [C1.1:2][0x7fccdf534820] 140517895636904:error:100000d7:SSL

routines:OPENSSL_internal:SSL_HANDSHAKE_FAILURE:/BuildRoot/Library/Caches/com.apple.xbs/Sources/boringssl_Sim/boringssl-109.200.32/ssl/ssl_lib.cc:1081: 2018-09-07 12:02:25.046072+0500 Networking[69467:3561679] [BoringSSL] boringssl_session_errorlog(224) [C1.1:2][0x7fccdf534820] [boringssl_session_read] SSL_ERROR_SSL(1): operation failed within the library 2018-09-07 12:02:25.046208+0500 Networking[69467:3561679] [BoringSSL] boringssl_session_handshake_error_print(205) [C1.1:2][0x7fccdf534820] 140517895636904:error:100000d7:SSL

routines:OPENSSL_internal:SSL_HANDSHAKE_FAILURE:/BuildRoot/Library/Caches/com.apple.xbs/Sources/boringssl_Sim/boringssl-109.200.32/ssl/ssl_lib.cc:1081: 2018-09-07 12:02:25.049462+0500 Networking[69467:3561679] [BoringSSL] boringssl_session_errorlog(224) [C1.1:2][0x7fccdf534820] [boringssl_session_read] SSL_ERROR_SSL(1): operation failed within the library 2018-09-07 12:02:25.049585+0500 Networking[69467:3561679] [BoringSSL] boringssl_session_handshake_error_print(205) [C1.1:2][0x7fccdf534820] 140517895636904:error:100000d7:SSL

routines:OPENSSL_internal:SSL_HANDSHAKE_FAILURE:/BuildRoot/Library/Caches/com.apple.xbs/Sources/boringssl_Sim/boringssl-109.200.32/ssl/ssl_lib.cc:1081: 2018-09-07 12:02:25.049732+0500 Networking[69467:3561679] [BoringSSL] boringssl_session_errorlog(224) [C1.1:2][0x7fccdf534820] [boringssl_session_read] SSL_ERROR_SSL(1): operation failed within the library 2018-09-07 12:02:25.049998+0500 Networking[69467:3561679] [BoringSSL] boringssl_session_handshake_error_print(205) [C1.1:2][0x7fccdf534820] 140517895636904:error:100000d7:SSL

routines:OPENSSL_internal:SSL_HANDSHAKE_FAILURE:/BuildRoot/Library/Caches/com.apple.xbs/Sources/boringssl_Sim/boringssl-109.200.32/ssl/ssl_lib.cc:1081:

如果我 运行 iOS 11.4 模拟器,那么控制台中的消息将是另一个消息,它会在大约 10-15 秒后出现:

[BoringSSL] Function boringssl_session_errorlog: line 2881 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert

如果我只是像往常一样尝试从 URL 获取数据,为什么控制台中会显示此消息?

似乎只是被删除的控制台垃圾:

希望对某人有所帮助。

别担心,这不是你的错。这是 OS 日志记录,幸运的是,您可以将其关闭。

打开产品▶️方案▶️编辑方案…… Select 运行 在环境变量上,添加值为 disable

的 OS_ACTIVITY_MODE