11

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 issue.

However, there is another point to consider. This issue is very specific to a project. This is because when I use po for other projects on same Macbook, it works immediately. Also, this particular project is slow on all other Macbook, and for all team.

I googled it but no relevant answer found. I find it easy to use print(...) rather than using debugging on Xcode console. However, it's more work and requires lots of rebuilds.

BLC
  • 2,240
  • 25
  • 27

2 Answers2

0

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.

Nol4635
  • 631
  • 1
  • 14
  • 24
0

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
Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90