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

2018-12-31 00:18发布

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条回答
心情的温度
2楼-- · 2018-12-31 00:47

use -fno-objc-arc for each file in build phases

查看更多
像晚风撩人
3楼-- · 2018-12-31 00:47

GO to App -> then Targets -> Build Phases -> Compile Source

Now, Select the file in which you want to disable ARC

paste this snippet "-fno-objc-arc" After pasting press ENTER

in each file where you want to disable ARC.

查看更多
唯独是你
4楼-- · 2018-12-31 00:48
  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

查看更多
只若初见
5楼-- · 2018-12-31 00:48
  1. select project -> targets -> build phases -> compiler sources
  2. select file -> compiler flags
  3. add -fno-objc-arc
查看更多
旧时光的记忆
6楼-- · 2018-12-31 00:49

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

查看更多
旧人旧事旧时光
7楼-- · 2018-12-31 00:50

Add flag “-fno-objc-arc”.

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

查看更多
登录 后发表回答