In Objective-C, the following code generates Unused variable warning:
- (void)viewDidLoad {
[super viewDidLoad];
NSInteger unusedVariable;
}
But in Swift, the following same code does not generate the warning:
override func viewDidLoad() {
super.viewDidLoad()
var unusedVariable: Int
}
Xcode version is 6.0.1.
Build Settings > Unused Variables is YES in Swift project.
Is this happening only to me?
How to make Swift or Xcode generate Unused variable warning in Swift?
According to Chris Lattner's post on the Apple Developer Forums, this is still a bug:
It's a known issue, we have a radar for it, thanks!
-Chris
Update: Not only does Swift now have unused variable warnings, it also is also yells at you when you use a var
where a let
would suffice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With