A blog about Swift and iOS tricks

A tip for debugging using compiler directives in Xcode

Here is a tip to help you debug your swift code in a better way in Xcode

import  UIKit

class HomeVC:  UIViewController {
    func  sayHi() { 
        //.....
        //sth cause failure let us print who is that guy
        print("failure \(#function) "in line \(#line) ", file \(#file)) 
    }
}

let  mainVC = HomeVC()
mainVC.sayHi()
 
/*
    output: failure sayHi() in line 9, fileMyPlayground.playground
*/