I have a project that contains some files that are using ARC, and some are not. The ones that are not have the compiler flag that disables ARC. That works fine.
I also want to make sure my library compiles for LLVM-GCC and also LLVM Compiler.
I have a property like this:
@property (strong, nonatomic) NSString *foo;
However, when I compile in LLVM-GCC, I get:
"Expected a property attribute before 'strong'"
If I change strong to retain, it compiles fine. Strong also works fine in LLVM Compiler.
What am I missing? Isn't strong synonymous with retain?
As Kevin indicates, if you're using ARC at any point in your static library project, it will only be compatible with the LLVM Compiler 3.0 and up.
However, if you want to create a framework that uses manual reference counting, yet is usable within ARC-enabled project and is compatible with older compilers, you might need to set up some compiler defines. We had to do this for the Core Plot framework in order to make the headers for that framework compatible across ARC and non-ARC projects built using a variety of compilers and targets.
To do this, I drew from Ryan Petrich's ZWRCompatibility, which he describes in his answer here, and assembled the following defines:
This lets you refer to non-retained (assigned) instance variables like the following:
with the matching property definition of
For targets of iOS 5.0 and Lion using the LLVM Compiler 3.0, this makes these properties use the safer
__weak
qualifier. For iOS 4.0 and Snow Leopard under LLVM Compiler 3.0, this turns to__unsafe_unretained
. Finally, for any other compiler, the qualifier is blank and the property is set toassign
.retain
can be used for properties without much of a problem across all compilers.You are using wrong complier. LLVM GCC does not supports Strong and other ARC keywords. Please set your complier as LLVM compiler 4.2
You're using an obsolete compiler and expecting it to support new language features. That simply isn't going to happen. If you're using keywords introduced with ARC, you need to be using Clang.