How to Disable Arc for a Single File in Xcode 5

How can I disable ARC for a single file in a project?

It is possible to disable ARC for individual files by adding the -fno-objc-arc compiler flag for those files.

You add compiler flags in Targets -> Build Phases -> Compile Sources. You have to double click on the right column of the row under Compiler Flags. You can also add it to multiple files by holding the cmd button to select the files and then pressing enter to bring up the flag edit box. (Note that editing multiple files will overwrite any flags that it may already have.)

I created a sample project that has an example: https://github.com/jaminguy/NoArc

xcode

See this answer for more info:
Disable Automatic Reference Counting for Some Files

How to disable ARC for a single file in Xcode 5?

Well, I just tried and found that you must had dragged the window to a smaller width. You need to drag it back to show the Compiler Flag column:

Sample Image

How can one turn ARC off for specific file

I've had this happen more than once for me in 4.2 in different projects, but then I've not been able to reproduce it reliably enough for a bug report. But I can say in my cases, a clean build cleared it up.

How to enable ARC for a single file

Add the -fobjc-arc flag to any files for which you'd like to enable ARC, as described in the ARC documentation.

Disable ARC with Xcode 5

If you want manual reference counting (using retains and releases) you can disable ARC in the build settings.

Select the project in the project navigator. The editor area should show you a view with four tabs: info, build settings, build phases, build rules. Select build settings.

To the left of those four titles, there should be a drop down list for selecting the target you want. Select the target you don't want ARC for.

Scroll down to find the section titled "Apple LLVM 5.0 - Language - Objective-C". Under there are three settings. The bottom one should be "Objective-C Automatic Reference Counting". Set that to "No" and you will have manual reference counting.

It might be a better option, however, to fix the reported problem. It's better to use ARC than not.

To Fix the error

You say your error occurred on the line where you create the obis array. This means that one or more of the following variables is an int instead of an object:

compteur1, compteur2, compteur3, compteur4, compteur5, nameC1, nameC2, nameC3, nameC4, nameC5

If you want to put an integer into an array, you have to box it as an NSNumber e.g.

NSArray* anArray = [NSArray arrayWithObjects: [NSNumber numberWithInt: 2], nil];

There is a shorthand form of writing that now, which looks like this:

NSArray* anArray =  @[ @(2) ];

Disable ARC in Xcode project

  1. Create yourself a new project
  2. Go to project settings, click the Target on the left
  3. Click Build Settings along the top
  4. Below that click All then in the search box type: automatic reference
  5. One build setting should now be showing, change the Yes to No

Your project is now MRC, explore away! HTH

How to enable/disable ARC in an xcode project?

Open your project and select Edit -> Refactor -> Convert to Objective-C ARC.
This will start checking your code if it is ready for the conversion.

See also Clang documentation: Objective-C Automatic Reference Counting (ARC)

How to disable ARC has been answered here

How can I disable ARC for an entire group/folder of files?

Goto Build Phases -> Compile sources select multiple files holding command ⌘ and press enter then add the value -fno-objc-arc It will reflect for all the selected files.

How to remove ARC from XCode

Click on the name of the project on the navigation view in the left side, go to Targets -> Build Phases and add -fno-objc-arc to the "compiler flags" for any relevant files.



Related Topics



Leave a reply



Submit