SwiftPrettyPrint
Parameterized-test for Swift. (with XCTest)
Pretty print that is Human-readable output than print()
and debugPrint()
in Swift standard library.
Motivation ?
print
and debugPrint
is implemented by standard library of Swift.
But both function is not readable output string to console sometime.
This is especially when using struct as ValueObject.
For example:
This output is enough information for debug,
but not human-readable for when forcusing on the values.
With SwiftPrittyPrint it looks like this:
Installation
CocoaPods (Recommended)
Carthage
Swift Package Manager
or add from Xcode 10+.
Recommend Settings ?
If you don't want to write import statement, I recommended to create Debug.swift
in each targets.
This can be not need to import
as follows:
Format options
You can configure format option, shared or passed by arguments:
Operator-based API
You can use operator based alias API that like Ruby.
This is no need to enclose in parenthese that convenient to long expression.
Operator syntax | Equatable to |
---|---|
Debug.p >>> 42 |
Debug.print(42) |
Debug.pp >>> 42 |
Debug.prettyPrint(42) |
Debug.pd >>> 42 |
Debug.debugPrint(42) |
Debug.ppd >>> 42 |
Debug.debugPrettyPrint(42) |
Xcode Code Snippets
Copy .codesnippet
files to the following directory from .xcode directory:
and restart Xcode.
Or run the following command from the root of the repository:
Develoopment
Require:
- Xcode 11.3
- pre-commit
Execute make setup
to install development tools to system (not include Xcode 11.3).