Xcode ToolsMidMCQ
What is the difference between `Debug` and `Release` build configurations?
Test your knowledge:
Explanation & Code
Answer: Build configurations control compiler optimisations and flags. Debug is for development; Release is what ships to users.
| Debug | Release | |
|---|---|---|
| Optimisation | None (-Onone) | Full (-O) |
| Debug symbols | ✅ Included | ❌ Stripped |
| Assertions | Active | Disabled |
#if DEBUG | true | false |
| Build speed | Fast | Slow |
| Runtime speed | Slow | Fast |
Code Example:
// Code only runs in Debug builds
#if DEBUG
func printDebugInfo() {
print("User: \(currentUser)")
print("API: \(apiBaseURL)")
}
#endif
// Assertion — removed in Release builds, no performance impact in production
assert(!items.isEmpty, "Items should never be empty here")
// Fatal error — always present (use for programmer errors)
guard let url = URL(string: urlString) else {
fatalError("Invalid hardcoded URL — developer error")
}
Rate your understanding: