In many languages I'm able to do something like this
printf("line number %d in file %s\n", __LINE__, __FILE__);
How can I get these debug identifiers in swift? I'd like to see a full list of available debug identifiers.
In many languages I'm able to do something like this
printf("line number %d in file %s\n", __LINE__, __FILE__);
How can I get these debug identifiers in swift? I'd like to see a full list of available debug identifiers.
With Swift 2.1 and below you are able to get these debug identifiers by
__FILE__
__LINE__
__COLUMN__
__FUNCTION__
__DSO_HANDLE__
Can be used like so
print("Function: \(__FUNCTION__), line: \(__LINE__)")
As of Swift 2.2 they may already be deprecated (time will tell) and replaced with
#namespace
#file
#line
#column
#function
#dsohandle
Can be used like so
print("Function: \(#function), line: \(#line)")
Sources:
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160201/008982.html
https://github.com/apple/swift-evolution/blob/master/proposals/0028-modernizing-debug-identifiers.md
https://bugs.swift.org/browse/SR-669