__FILE__ is deprecated and will be removed in swift 3

Viewed 2146

I have this line of code

NSLog("\(__FILE__)  \(__LINE__)  \(__COLUMN__)  \(__FUNCTION__)")

I updated to xcode 7.3 and I now get a warning that states that this method has been deprecated and will be removed in swift 3.

I tried changing the code to

NSLog("\(#file)  \(#line)  \(#column)  \(#function)")

but I still get the same warning. What is causing this?

1 Answers

It works fine with print and maybe wrap it into a public funciton:

public func superLog(_ fileName: String, definition: String, lineNumber: Int, variable: String, value: Any) { let fn = fileName.replacingOccurrences(of:"/Users/userName/Documents/IOS/project/", with: "") print("\n \(fn) \(lineNumber)\n \(definition)\n\n(variable)\n➳",value,"\n") } superLog(#file, definition: "log", lineNumber: #line, variable: "var", value: value)

Related