Logging, assert/precondition/fatalError
Log state with print/debugPrint , and choose between assert (debug-only), precondition (checked in release), and fatalError (crash) for invariants.
Diagnostics toolbox
Use simple logging to see state; enforce assumptions with assert, precondition, and fatalError.
- assert: debug-only checks
- precondition: checked in release too
- fatalError: stop immediately
Lightweight logging
print is readable; debugPrint shows more detail (useful while debugging).
let user = ["name": "Ana", "role": "admin"]
print("User:", user) // user-friendly
debugPrint("User:", user) // includes type details when available
let point = (x: 3, y: 5)
print("Point:", point)
debugPrint("Point:", point)All lessons in this course
- XCTest basics (targets, fixtures)
- Logging, assert/precondition/fatalError