Suppress property definition warning with LLVM 3.0 in ObjC code

Since Xcode 4.2 ships with LLVM 3.0, we can finally use automatic synthesizing. You can enable it by adding the following two flags to Other C Flags under Apple LLVM compiler 3.0 - Language :

  • -Xclang
  • -fobjc-default-synthesize-properties

Now you can get rid of your @synthesize code table code if you just need the default settings for your property @synthesize (I think we already use automatic link counting).

When I click build, the compiler warns me of missing @synthesize instructions, etc .:

 MyController.h:34:43: warning: property 'myProperty' requires method 'myProperty' to be defined - use @synthesize, @dynamic or provide a method implementation [3] @property (strong, nonatomic) MyClass *myProperty; 

I prefer creation without warning, so the question is : How can I suppress this kind of warnings, because obviously they no longer make sense.

+4
source share
2 answers

Are you sure -Xclang is passed to the compiler

 clang -x objective-c -Xclang -fobjc-default-synthesize-properties -c TestClass.m -o TestClass.o 

no warnings are displayed, and

 clang -x objective-c -fobjc-default-synthesize-properties -c TestClass.m -o TestClass.o 

is this correct, since no properties are synthesized

This uses TestClass.m:

 #import <Foundation/Foundation.h> @interface TestClass : NSObject @property (nonatomic, strong) NSObject * test; @end @implementation TestClass @end 
+4
source

Ok, I managed to suppress this warning using these C flags:

 -Xclang -fobjc-default-synthesize-properties -Wno-objc-property-implementation 

Unfortunately, getters / seters are not synthesized (... and actually my application crashes ...)

0
source

All Articles