swift – Strange error nw_protocol_get_quic_image_block_invoke dlopen libquic failed

swift – Strange error nw_protocol_get_quic_image_block_invoke dlopen libquic failed

I faced the same error in a different context, in XCode 12.0.1 too. It might not be related, but I suspect its an issue with accessing the run loop of the main thread. I was just trying out some introductory code I found online, and faced the same issue, so this is a bug, rather than a problem with your code. Heres how you can get a piece of code that has the same issue:

git clone git@github.com:BestKora/CS193P-Fall-2017-Demo-iOS12.git
cd CS193P-Fall-2017-Demo-iOS12/Cassini L10
xed . # this opens XCode (CLI tool stands for XCode editor)

Having said that, by rewriting the code, I was able to prevent this issue. Maybe you can find something amongst the code below to fix your specific issue:

Specifically, instead of using the following (DispatchQueue.global)

    private func fetchImage() {
        if let url = imageURL {
            spinner.startAnimating()
            DispatchQueue.global(qos: .userInitiated).async { [weak self] in
                let urlContents = try? Data(contentsOf: url)
                DispatchQueue.main.async {
                    if let imageData = urlContents, url == self?.imageURL {
                        self?.image = UIImage(data: imageData)
                    }
                }
            }
        }
    }

I use URLSession.shared.dataTask, and this error no longer happens:

    private func fetchImage() {
        print(fetching image)
        if let url = imageURL {
            
            let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
                guard let data = data else {
                    return
                }
                // maybe try dispatch to main
                DispatchQueue.main.async {
                    self.imageView.image = UIImage(data: data)
                }
            }
            task.resume()
        }
    }

I had same issue in an Widget Target, but solved it by adding public to the variables.

Fixed struct is shown below.

struct LastCommitEntry: TimelineEntry {
    public let date: Date
    public let commit: Commit
}

swift – Strange error nw_protocol_get_quic_image_block_invoke dlopen libquic failed

Restarting my simulator did the trick.

Leave a Reply

Your email address will not be published.