Remove println() for release version iOS Swift

前端 未结 19 1524
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 15:55

I would like to globally ignore all println() calls in my Swift code if I am not in a Debug build. I can\'t find any robust step by step instructions for this a

19条回答
  •  难免孤独
    2020-11-29 16:58

    My Solution is use this code in AppDelegate before class

    // Disable console log in live app
    #if !arch(x86_64) && !arch(i386)
        public func debugPrint(items: Any..., separator: String = " ", terminator: String = "\n") {
    
        }
        public func print(_ items: Any..., separator: String = " ", terminator: String = "\n") {
    
        }
    #endif
    
    class AppDelegate: UIResponder, UIApplicationDelegate {
    // App Delegate Code 
    
    }
    

提交回复
热议问题