swiftxcodedebugging

Is there a way to print the current line number in XCode?


Does XCode have some sort of macro which outputs the current line number?

For trouble shooting I add a few print() statements, and currently manually insert the line number. Something like this:

print("73: \(value)")

It would be nice if XCode count insert the line number for me.

I’m using Swift.


Solution

  • It's available, try this:

    print("\(#line): \(value)")
    

    You're also able to print out #function, #file, etc... take a look at this Literal-Expression