64

In new Xcode 6.3 I get this warning:

Auto property synthesis will not synthesize property 'homeInt'; it will be implemented by its superclass, use @dynamic to acknowledge intention

How I can remove it?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
UnRewa
  • 2,462
  • 2
  • 29
  • 31

7 Answers7

113

If you are overriding the same property from the super class on purpose, then in your *.m or *.mm file, add @dynamic like:

@implementation MyClass

@dynamic homeInt;

// ...

@end

If not, rename the property.

Top-Master
  • 7,611
  • 5
  • 39
  • 71
Karmeye
  • 1,399
  • 1
  • 8
  • 16
64

I simply removed this property declaration, because it has already been declared in parent class

stasick
  • 680
  • 6
  • 6
10

Following on @mplace's comment, in my case I was overriding the property to refine the type of the property to a subclass of the original class of the property. So, I did need the @property override.

Here's what I'm using:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-property-synthesis"
// superclass type for currentValue was "id"
@property (nonatomic, strong) NSDate *currentValue;
#pragma clang diagnostic pop

Note that it's "-Wobjc-property-synthesis" and not "-Wno-objc-property-synthesis"

See also https://github.com/couchbase/couchbase-lite-ios/issues/660

Chris Prince
  • 7,288
  • 2
  • 48
  • 66
5

If you want to avoid adding @dynamic <varName> each place that you have overridden a super class's property intentionally, you can add the -Wno-objc-property-synthesis flag to "Other Warning Flags" under your projects build settings. This will suppress the warning project-wide.

mplace
  • 59
  • 3
  • This isn't suppressing the warnings for me... I'm using Cocoapods, not sure if that is overriding my flags. – AnthonyMDev May 05 '15 at 21:11
  • -Wno-objc-property-synthesis does not work for me either to suppress this warning. Any one else have ideas? – Chris Prince May 07 '15 at 23:20
  • Let me refine that. It doesn't work when I put it inline with the code with "#pragma clang diagnostic ignored", but it does work when I put it with the compiler flags. I'd rather not make it general across all my code with the compiler flags... – Chris Prince May 07 '15 at 23:27
3

this cause by child class define the same property name override to parent class,such as:
1)child class "AFHTTPSessionManager" have define :

@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * **responseSerializer**;

2)parent class "AFURLSessionManager" have define:

@property (nonatomic, strong) id <AFURLResponseSerialization> **responseSerializer**;

3)cause by above, warning come! if want remove it ,just rename the conflict property name!
4) or as it suggest, add "@dynamic homeInt" in your implement file;

zmingchun
  • 418
  • 6
  • 9
  • I see the same warnings for AFNetworking. Question is, are these anything to be concerned about? Do they even need attention for this library – Bradley Thomas Apr 09 '15 at 13:38
  • 2
    it has fixed! https://github.com/AFNetworking/AFNetworking/commit/3fc8071582dfa552cb06b0dc7f1104c6bf5301f1 @BradThomas – zmingchun Apr 09 '15 at 15:00
  • 1
    I'm glad I'm not the only one who accidentally ends sentences with a semicolon; – hyperspasm May 17 '15 at 16:46
0

If you updated to Xcode 6.3, simply update AFNetworking to version 2.5.2 and these warnings should disappear.

Marcos Reboucas
  • 3,409
  • 1
  • 29
  • 35
  • 3
    This is correct for warnings resulting from AFNetworking properties. The original question wasn't about one of those though. – ecotax Apr 23 '15 at 07:16
0

@synthesize homeInt = _ homeInt;
...

@end
koen
  • 5,383
  • 7
  • 50
  • 89