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

前端 未结 18 2926
星月不相逢
星月不相逢 2020-11-21 04:31

I am using ARC successfully in my project. However, I have encountered a few files (e.g., in unit tests and mock objects) where the rules of ARC are a little more fragile ri

相关标签:
18条回答
  • 2020-11-21 05:14

    Just use the -fno-objc-arc flag in Build Phases>Compile Sources

    0 讨论(0)
  • 2020-11-21 05:14

    Following Step to to enable disable ARC

    Select Xcode project Go to targets Select the Build phases section Inside the build phases section select the compile sources. Select the file which you do not want to disable ARC and add -fno-objc-arc

    0 讨论(0)
  • 2020-11-21 05:15

    Add flag “-fno-objc-arc”.

    Simple follow steps : App>Targets>Build Phases>Compile Sources> add flag after class “-fno-objc-arc”

    0 讨论(0)
  • 2020-11-21 05:20

    For Xcode 4.3 the easier way might be: Edit/Refactor/Convert to objective-C ARC, then check off the files you don't want to be converted. I find this way the same as using the compiler flag above.

    0 讨论(0)
  • 2020-11-21 05:21

    Note: if you want to disable ARC for many files, you have to:

    1. open "Build phases" -> "Compile sources"
    2. select files with "left_mouse" + "cmd" (for separated files) or + "shift" (for grouped files - select first and last)
    3. press "enter"
    4. paste -fno-objc-arc
    5. press "enter" again
    6. profit!
    0 讨论(0)
  • 2020-11-21 05:21

    I think all the other answers are explaining how to disable MRC(Manual Reference Count) and enabling ARC(Automatic Reference Count). To Use MRC(Manual Reference Count) i.e. Disabling ARC(Automatic Reference Count) on MULTIPLE files:

    1. Select desired files at Target/Build Phases/Compile Sources in Xcode
    2. PRESS ENTER
    3. Type -fobjc-arc
    4. Press Enter or Done
    0 讨论(0)
提交回复
热议问题