First of all, we should know that the entrance to Swift's program is in Appdelegate.swift. So in the print log in Appdelegate.swift this is the case
Import Uikit@uiapplicationmainclassAppdelegate:uiresponder, uiapplicationdelegate {var window:uiwindow?func Application (application:uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject:anyobject]< /c3>?) -Bool {dllog ("Hello") return true }}//write the log to be printed in the same rank with appdelegate method, that is, do not belong to the Appdelegate class, so that in the project to use this print log, because this is the program's entrance,//the t here means that the message parameter type is not specifiedFunc dllog<t> (message:t, filename:string = __file__, funcname:string = __function__, Linenum:int =__line__) { #ifDEBUG/** * Here also search for swift flags in the project build settings, find other Swift flags find Debug * Add-D debug, can. */ //1. Processing the fileLet file = (fileName asnsstring). Lastpathcomponent//2. Print ContentPrint ("[\ (file)][\ (funcName)] (\ (linenum)) \ (message)") #endif }
The type of printing is:[Appdelegate.swift][application (_:didfinishlaunchingwithoptions:)] (+) Hello
The contents of the file method name line number, respectively
Secondly, one thing that should be dealt with is that (in fact, it is explained in the code)
This completes the log log in the full debug state.
Print logs in debug state in Swift