Disable Automatic Reference Counting for Some Files
I have downloaded the iOS 5 SDK and found that ARC is a great feature of the new Apple compiler. For the time being, many third party frameworks don’t support ARC. Could I use ARC for my new code and keep the current retain/release code unchanged? The ARC converter doesn’t work here, because some frameworks, such as JSONKit, cannot be converted to ARC by using the converter.
The answer is to add
-fno-objc-arc to the compiler flags for the files you don’t want ARC. In Xcode 4, you can do this under your target -> Build Phases -> Compile Sources.
5 Solutions Collect From Internet About “Disable Automatic Reference Counting for Some Files”
The public ARC docs, while not directly clear on this point, seem to suggest that as long as each class is either all ARC or all manually-managed, the classes can be integrated into a single program.
You only can’t mix ARC and non-ARC in a single class; the document says that sending
retainCount messages by any means (including timers and delayed performs, which use
@selector) is banned in ARC code. So you can’t do non-ARC in an ARC class (because the necessary messages are banned) and you can’t do ARC in a non-ARC class (because ARC adds syntax elements that are invalid without ARC).
The same document is a bit clearer on whether you can integrate non-ARC libraries/frameworks into an ARC program: Yes. It doesn’t mention whether you can use ARC libraries/frameworks in a program where all your code is non-ARC, but given all of the above, the implication seems to be yes.
It is not very intuitive how to disable ARC on MULTIPLE files, for a while I was do it one by one until a figured out how to do that.
- Select desired files at Target/Build Phases/Compile Sources in Xcode (CMD+click or Shift+click)
- PRESS ENTER (double click will reset the selection, so it does’t work)
- Type -fno-objc-arc
- Press Enter or Done
If you want to disable Automatic Reference Counting for some Files then its really simple to do just follow the steps.You add compiler flags in Targets -> Build Phases -> Compile Sources.
The flag used is -fno-objc-arc press enter after writing it.!
You have to double click on the right column of the row under Compiler Flags.
Hope it helps Thanks 🙂
It is possible to disable ARC for individual files by adding the -fno-objc-arc compiler flag for those files.
How can I disable ARC for a single file in a project?
To disable ARC for individual classes you will need to go to Build Phases after clicking your project in Xcode and expand the compile sources sections.
On the right side you will see the option to add compiler flags for the specific classes. Setting -fno-objc-arc for the class will disable ARC on it.
Disable Automatic Reference Counting with -fno-objc-arc
- iOS show UIImage full screen with zooming (pinch and double tap) enabled
- Get character before cursor in Swift
- PyObjC on Xcode 4
- how to pass variable arguments to another method?
- Are keys stored in the iOS or iCloud Keychains visible to the user?
- Strong and weak references in Swift
- Phonegap IOS – Plugin Push Setup
- how to prevent saving picture from camera roll again
- display route on iOS 7 maps: addOverlay has no effect
- Change background color with a variable iOS
- Detect permission of media library ios
- Variable IBOutlet name for a UILabel?
- Using Core Plot 2 in an Xcode 5 project
- Uploading archive error: “Missing iOS Distribution signing identity for …”
- Set iPhone date/time within app for testing purposes?