With multiple #define it is entirely possible to write source files that compile correctly for multiple MRC, ARC, and GC.
Xcode does not allow you to include both ARC and GC, knowing that we can write:
#if defined(__OBJC_GC__) # define USING_GC 1 #else # define USING_GC 0 #endif #if __has_feature(objc_arc) # define USING_ARC 1 #else # define USING_ARC 0 #endif #if USING_ARC || USING_GC # define USING_MRC 0 #else # define USING_MRC 1 #endif
which will only define one of USING_GC , USING_MRC and USING_ARC as 1 , and the other two as 0 . You can put this in the project prefix header (.pch).
You can use these definitions directly in your code to include / exclude things like bridges; or it is better to define macros for memory calls, castings, etc. that expand to the appropriate code based on the memory model used.
NTN
source share