Add error when building without ARC #541

merged 1 commit into from Sep 27, 2012


None yet

2 participants


Test if ARC is on, and fail with an #error if not.

This is done in a source file, not a header, so it imposes no constraints on the calling code.

This may be worth adding to each source file, but I thought I'd start with a central one.

@mattt mattt merged commit 1ca61bf into AFNetworking:master Sep 27, 2012

Come to think of it __has_feature is NSHipster blog-worthy. Given all of the confusion about AFN recently with the switch to ARC, this snippet should be included in every open source project using ARC. Good stuff. Thanks!


I hadn't heard of NSHipster, and I'm now following it. So thanks for the pointer, too!


Mattt, the more I think of this, the more I think it's a good addition to every source file. The reason is just that the user/developer can technically satisfy the check by adding -fobjc-arc to just that one file. While that might seem like a crazy case, it'd be pretty easy to miss one of the AFNetworking files.

Also, some of the add-ons still require ARC be off.


I think I'm fine with just having the error in a single class, at least for now. If people are still asking about ARC support after this change, we can consider more drastic measures.

As for the addons, I'll work to get those all ARC-ified so that they're all internally-consistent.


Sounds good. My guess is that error will reduce the problem by 80% or more. What's left should be manageable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment