xcode - Remove println() for release version iOS Swift -
i globally ignore println() calls in swift code if not in debug build. can't find robust step step instructions , appreciate guidance. there way globally, or need surround every println() #if debug/#endif statements?
the simplest way put own global function in front of swift's println:
func println(object: any) {     swift.println(object) } when it's time stop logging, comment out body of function:
func println(object: any) {     // swift.println(object) } or can make automatic using conditional:
func println(object: any) {     #if debug         swift.println(object)     #endif } edit in swift 2.0 println changed print. unfortunately has variadic first parameter; cool, means can't override because swift has no "splat" operator can't pass variadic in code (it can created literally). can make reduced version works if, case, printing 1 value:
func print(items: any..., separator: string = " ", terminator: string = "\n") {     swift.print(items[0], separator:separator, terminator: terminator) } in swift 3, need suppress external label of first parameter:
func print(_ items: any..., separator: string = " ", terminator: string = "\n") {     swift.print(items[0], separator:separator, terminator: terminator) } 
Comments
Post a Comment