How can I disable ARC for a single file in a proje

2019-08-06 21:23发布

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 right now. I recall hearing that there was a way to disable ARC on a per-file basis, though I have been unable to find this option.

Is this possible? How do I disable ARC on a per-file basis?

18条回答
Emotional °昔
2楼-- · 2019-08-06 22:18
  1. select project -> targets -> build phases -> compiler sources
  2. select file -> compiler flags
  3. add -fno-objc-arc
查看更多
爷、活的狠高调
3楼-- · 2019-08-06 22:20

Disable ARC on MULTIPLE files:

  1. Select desired files at Target/Build Phases/Compile Sources in Xcode
  2. PRESS ENTER
  3. Type -fno-objc-arc
  4. Press Enter or Done

;)

enter image description here

查看更多
叼着烟拽天下
4楼-- · 2019-08-06 22:20
  1. Select Xcode project
  2. Go to targets
  3. Select the Build phases section
  4. Inside the build phases section select the compile sources.
  5. Select the file which you do not want to disable ARC and add -fno-objc-arc

Disable ARC for a particular file

查看更多
Bombasti
5楼-- · 2019-08-06 22:20

Add flag “-fno-objc-arc”.

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

查看更多
爷、活的狠高调
6楼-- · 2019-08-06 22:20

Just use the -fno-objc-arc flag in Build Phases>Compile Sources infront of files to whom you dont want ARC to be apply.

查看更多
Summer. ? 凉城
7楼-- · 2019-08-06 22:22

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

查看更多
登录 后发表回答