LoginSignup
5
3

More than 3 years have passed since last update.

【Swift】Debug時のみ、ログ出力を行うprint,dump

Posted at

Debug時のみ、ログ出力を行うprint,dump

    static func dump<T>(_ value: T, name: String? = nil, indent: Int = 0, maxDepth: Int = Int.max, maxItems: Int = Int.max) {
        #if DEBUG
        Swift.dump(value, name: name, indent: indent, maxDepth: maxDepth, maxItems: maxItems)
        #endif
    }

    static func print(_ items: Any...) {
        #if DEBUG
        Swift.print(items)
        #endif
    }

Build Settings > Other Swift Flags に 「-D DEBUG」を忘れずに!

Screen Shot 2019-09-13 at 10.15.17 PM.png

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3