如何在 xcode 项目中启用/禁用 ARC?

发布于 2024-12-29 08:55:12 字数 35 浏览 4 评论 0原文

如果创建的项目已禁用 ARC,我该如何启用它,反之亦然?

If a project has already been created with ARC disabled, how do I enable it and vice versa?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

云淡风轻 2025-01-05 08:55:12

打开您的项目并选择编辑 ->重构->转换为 Objective-C ARC。
这将开始检查您的代码是否已准备好进行转换。

另请参阅 Clang 文档:Objective-C 自动引用计数 (ARC)

如何禁用 ARC已在此处得到解答

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

柳絮泡泡 2025-01-05 08:55:12

以下是我所做的步骤,它对我有用

  1. 选择Project
  2. 选择Targets
  3. 从右侧面板中,选择Build Settings
  4. 搜索“Automatic Reference”计数”;
  5. 找到 Apple LLVM 编译器 3.0 - 语言Objective-C 自动引用计数,并在所有三个部分中选择 NO

在此处输入图像描述

Following are the steps which I did and it worked for me

  1. Select Project
  2. Select Targets
  3. From the right panel, select Build Settings
  4. Search for "Automatic Reference Counting";
  5. Locate Apple LLVM compiler 3.0 - Language and Objective-C Automatic Reference Counting and select NO in all three sections.

enter image description here

凡间太子 2025-01-05 08:55:12

当您迁移项目以使用 ARC 时,-fobjc-arc 编译器标志将设置为所有 Objective-C 源文件的默认值。您可以使用特定类的 -fno-objc-arc 编译器标志来禁用该类的 ARC。在 Xcode 的目标“构建阶段”选项卡中,打开“编译源”组以显示源文件列表。双击要设置标志的文件,在弹出面板中输入 -fno-objc-arc,然后单击“完成”。

When you migrate a project to use ARC, the -fobjc-arc compiler flag is set as the default for all Objective-C source files. You can disable ARC for a specific class using the -fno-objc-arc compiler flag for that class. In Xcode, in the target Build Phases tab, open the Compile Sources group to reveal the source file list. Double-click the file for which you want to set the flag, enter -fno-objc-arc in the pop-up panel, then click Done.

2025-01-05 08:55:12

在 Xcode 5.0.2 中,在 Navigatior 中选择您的项目,选择“构建设置”,搜索 Apple LLVM 5.0 - Language - Objective C 并将 Objective-C 自动引用计数更改为 NO

In Xcode 5.0.2, select your project in Navigatior, select Build Settings, search for Apple LLVM 5.0 - Language - Objective C and change Objective-C Automatic Refence Counting to NO

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文