Reputation: 2973
Xcode 4.3 doesn't warn about undeclared methods when they exist in the current
@implementation
, which is a great new feature. However, this is causing an issue in certain circumstances when using my project on Xcode 4.2.
How do I re-enable the warnings for undeclared methods?
For example:
@interface MashTun : NSObject
- (void)foo;
@end
@implementation MashTun
- (void)foo {
CGRect rect = [self smallRect];
NSLog(@"My Small Rect: %@", NSStringFromCGRect(rect));
}
- (CGRect)smallRect {
return CGRectMake(0, 0, 100, 100);
}
@end
In Xcode 4.2, this fails:
warning: instance method '-smallRect' not found (return type defaults to 'id')
error: initializing 'CGRect' (aka 'struct CGRect') with an expression of incompatible type 'id'
I completely understand the warning and error in Xcode 4.2 since it's not allowing the search for methods within the current @implementation
scope. (The fix is simple: either put the smallRect
method above the foo
method, or declare the smallRect
method in a category or the header. )
But how do I turn on a warning in Xcode 4.3 to catch this error before passing it on to colleagues running 4.2?
Upvotes: 9
Views: 1452
Reputation: 104708
one option during such a transition would be to cross-compile with another compiler/version. gcc-llvm is one common, preinstalled alternative. another approach would be to install multiple versions of xcode and build using that toolchain.
Upvotes: 0
Reputation: 320
I don't know If I might have a funny build but my LLVM 3.1 Compiler does have the Undeclared Selector Flag under the Compiler Warnings. Currently running 4.3.2. the LLVM 4.0 does not have it though.
Upvotes: 0
Reputation: 2527
The new LLVM 3.1 compiler does not care about this. It does not matter if you place the method above/below or whether there is a prototype. So if all your colleagues have their Xcode updated to at least 4.3. This really should not be an issue.
Another option is to create your own warning using the code below. You cold inform them of this issue, and problem at hand. This might be an easy way to get the message across.
#warning "warning message"
Hope this helps.
Upvotes: 0