MechanismProductionTestingDebugging
fatalError() in SwiftTerminates the app unconditionallyTerminates the testTerminates the app unconditionally
assertions in SwiftCompletely ignored, no effectCauses test failure if condition failsTerminates the app if condition fails
Logger’s .error(_:)Logs error message without terminatingLogs error message without failing testsLogs error message without terminating
Logger’s .info(_:)Logs informational messageLogs informational messageLogs informational message
[[IssueReporting|reportIssue()]] by pointfree.coShows unobtrusive warnings by default (customizable)Becomes a test failureShows purple runtime warnings in Xcode

Better Printing

While debugging, it can be easy to get overloaded with irrelevant and poorly formatted logs in the console. Here are some strategies that can help.

Custom Type Summaries

From: (25:07) WWDC24: Run, Break, Inspect: Explore effective debugging in LLDB | Apple - YouTube

Annotate your types with the @DebugDescription macro (after Swift 6).1

@DebugDescription
 
struct WatchLaterItem {
	let video: Video
	let name: String
 
	let addedOn: Date
	var debugDescription: String {
		"\ (name) - \(addedOn)"
	}
}

See also

Resources

Footnotes

Footnotes

  1. This strategy makes it so you no longer need to use the LLDB command po and can instead use p consistently everywhere.

0 items under this folder.