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:
#if TARGET_OS_IPHONE && defined(__IPHONE_5_0) && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0) && __clang__ && (__clang_major__ >= 3)
#define CPT_SDK_SUPPORTS_WEAK 1
#elif TARGET_OS_MAC && defined(__MAC_10_7) && (MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7) && __clang__ && (__clang_major__ >= 3)
#define CPT_SDK_SUPPORTS_WEAK 1
#else
#define CPT_SDK_SUPPORTS_WEAK 0
#endif
#if CPT_SDK_SUPPORTS_WEAK
#define __cpt_weak __weak
#define cpt_weak_property weak
#else
#if __clang__ && (__clang_major__ >= 3)
#define __cpt_weak __unsafe_unretained
#else
#define __cpt_weak
#endif
#define cpt_weak_property assign
#endif
This lets you refer to non-retained (assigned) instance variables like the following:
__cpt_weak CPTAnnotationHostLayer *annotationHostLayer;
with the matching property definition of
@property (nonatomic, readwrite, cpt_weak_property) __cpt_weak CPTAnnotationHostLayer *annotationHostLayer;
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 to assign
.
retain
can be used for properties without much of a problem across all compilers.