Xcode takes long time to print debug results.

后端 未结 2 1170
清酒与你
清酒与你 2021-02-20 04:46

When I debug on Xcode it takes around 30 seconds or more to print results of po on Xcode console.

Unfortunately, this is only few information I have on the

2条回答
  •  天命终不由人
    2021-02-20 05:10

    Swift:

    Try this solution which helps to reduce log time in debug mode.

    Step 1: Create a new file called Utils.swift (File name based on your preference)

    Step 2: Add following code in file

    import Foundation
    import UIKit
    
    struct Utils { }
    public func PrintLogs(_ message: Any, file: String = #file, function: String = #function, line: Int = #line) {
        #if DEBUG
        let className = file.components(separatedBy: "/").last ?? ""
        let classNameArr = className.components(separatedBy: ".")
        NSLog("\n\n--> Class Name:  \(classNameArr[0]) \n--> Function Name: \(function) \n--> Line: \(line)")
        print("--> Log Message: \(message)")
        #endif
    }
    

    Usage: Call PrintLogs("Hello") instead of print("Hello")

    Sample Output:

    --> Class Name:  HomeViewController 
    --> Function Name: logTest() 
    --> Line: 81
    --> Log Message: Hello
    

提交回复
热议问题