WWDC 2017
Session video and resources: https://developer.apple.com/videos/play/wwdc2017/406/
- Detects misuses of common APIs
- Available in the diagnostics tab of a scheme, under "Run"
- Also can pause on issues for a better understanding
- Supports AppKit, UIKit, WebKit
- Swift and C languages
- Does not require recompilations
- Enabled by default on XCode 9
- Good APIs should also provide queue as a parameter to specify where the code will be running
- Detects use-after-scope
- Detects use-after-return
- These both prevents access to the pointers created in previous scopes to prevent leaks and crashes
- Better to use if there is a C & Obj-C mixed project with pointers
- Detects multithreading issues
- Find races even if they did not manifest
- Only on 64 bit macOS and simulators
- Unsync access to shared mutable vars
class EventLog {
private var lastEventSource: LogSource?
func log(source: LogSource, message: String) {
print(message)
lastEventSource = source
}
}
// Thread 1
eventlog.log()...
// Thread 2
eventlog.log()...
/// This is a data race, solve it by dispatch queues so func() runs asynchronously in a GCD Queue
- Associate your data with serial dispatch queues
- Swift and Obj-C collection races are also detected
- Use GCD to synchronize access to the data
- Runtime bug finder
- Checks unsafe constructs in the C language family
- Compatible with other runtime tools
- Detects a possible integer overflow
- Unaligned load or store
- Causes crashes in Release builds
- Undefined Behaviour Sanitizer is available under build settings
- Exercise more code
- Use runtime tools for daily development
- Use them before every release
- Use CI with these tools turned on (WWDC 2015 -> CI and Code Coverage Session)
- Combine different tools
- Turning these tools on can cause execution and memory overhead up to 10x times