JUCE and ARC


#1

When adding a .m or .mm file with the Projucer is there anyway to specific you want ARC enabled for that file? -fobjc-arc?


#2

We don’t store any file-specific flags at all… Is it even possible to safely link together object files that are compiled with and without ARC?


#3

As far as I know, yes, this is possible.
In Xcode, in the Project settings/Build Phases tab there’s a “Compile Sources” section where you can add specific Compiler Flags for each file.
So, for instance, you can add -fno-objc-arc if you want to compile a non-ARC file within a project that uses ARC and -fobjc-arc if you want to do the opposite.
In order to avoid misuses, I usually add this at the beginning of a file (.m or .mm) that I know is going to be added to new projects where ARC is not enabled:

#if ! __has_feature(objc_arc)
#error This file must be compiled with ARC. Either turn on ARC for the project or use -fobjc-arc flag
#endif

This said, it would be great if JUCE’s native bindings for iOS and macOS could finally migrate to ARC (it’s 2018…).
Cheers!


#4

Yes, as masshacker says, no issues combining arc and non-arc code.