9
votes

Reading ProgrammingWithObjectiveC, I can say:

There’s no need to specify the strong attribute explicitly, because it is the default.

If I omit the 'strong' attribute for a property in my project like this,

@property (nonatomic) NSString *string;

it gives me a warning:

No 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed

aka.

-Wobjc-property-no-attribute

So somehow the compiler seems to be thinking that I´m still doing manual reference counting, otherwise there wouldn´t be any warning.

Also, when creating a new empty project, it doesn´t warn me when there´s no 'strong' attribute, so it must have something to do with the current project settings, maybe even some flag that isn´t reachable via the UI. The project is a rather old one (~2 years) and has undergone several migration steps in the meantime (XCode 3 > 4 > 5, Non-ARC > ARC etc.).

I´ve looked everywhere in the project settings, but somewhere seems to be a missing checkmark or something.

Anyone experiencing the same problem?

2
I did not experience that problem, but in your build log there should be a warning identifier -Wsomething. Perhaps that gives some clue. Knowing the warning you can explicitly disable it with the -Wno-something compiler flat.Martin R
I don´t want to disable the warning, I wanna know what´s wrong with the compiler. :)stk
I understand that (and I don't know where it comes from). My idea was that "name" of the warning might give some hint. Did you find it in the build log?Martin R
It´s -Wobjc-property-no-attributestk
Can you show the concrete property declaration that causes the warning?Martin R

2 Answers

3
votes

Just searched for it, and the closest build property would be CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES which I doubt has any relationship.

You can check which default parameters your target overrides by selecting "All" and "Levels" options in the Build Settings view.

enter image description here

Check for the warnings that default to No but are being turned into Yes by your target.

1
votes

Make sure you have the latest version of Xcode. This is a new compiler feature and how it works has changed several times in recent updates.

Make sure your project is configured to use clang/llvm and not gcc. I can't remember if gcc supports ARC at all (can someone comment of they do know?) but it definitely doesn't support all the features. And an old Xcode project will be using gcc unless you changed it. All recent language changes are only implemented in clang/llvm

Do you have ARC enabled? That will change the behaviour as we'll beware ARC can be enabled or disabled project wide or for specific files.

Some changes in Xcode only apply to new projects, and old projects have are configured to disable them. Have a look over the settings for anything related to ARC that is not set to the default value.