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


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」を忘れずに!