Xcode takes long time to print debug results.

后端 未结 2 1157
清酒与你
清酒与你 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
    
    0 讨论(0)
  • 2021-02-20 05:25

    I have several explanations:

    1. There is a lot of code (Xcode slows down after a certain amount of code) Also make sure your print statement is towards the top of your page. Xocde goes from top to bottom.

    2. Your Mac is slow. Some Macs after a certain amount of usage slow down. Also if you have a Mac mini or air they are slower than others.

    3. Xcode Beta. If you are using Xcode beta then there might just be a bug.

    If none of those answer you provide me with more info and I provide other solutions.

    0 讨论(0)
提交回复
热议问题