kean / Pulse

Network logger for Apple platforms

Home Page:https://pulselogger.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Xcode 15.3 reports that Pulse is performing I/O on the main thread, which can lead to app hangs

Taeeun-Kim opened this issue · comments

Xcode version: 15.3
Pulse version: 4.0.5

Error:

{"message":"This code path does I/O on the main thread underneath that can lead to UI responsiveness issues. Consider ways to optimize this code path","antipattern trigger":"-[NSData initWithContentsOfURL:options:error:]","message type":"suppressable","show in console":"0"}

Code:

extension LoggerStore {
    private struct Manifest: Codable {
        var storeId: UUID
        var version: Version
        var lastSweepDate: Date?

        init(storeId: UUID, version: Version) {
            self.storeId = storeId
            self.version = version
        }

        init?(url: URL) {
            guard let data = try? Data(contentsOf: url),
                  let manifest = try? JSONDecoder().decode(Manifest.self, from: data) else {
                return nil
            }
            self = manifest
        }
    }
}

image