使用 XCode 5.0.2 将问题从非 ARC 迁移到 ARC

Posted

技术标签:

【中文标题】使用 XCode 5.0.2 将问题从非 ARC 迁移到 ARC【英文标题】:Migrating issue from non ARC to ARC with XCode 5.0.2 【发布时间】:2013-12-12 12:16:46 【问题描述】:

我听说过 ARC,我也将它与 XCode 4.2 一起使用,但现在我需要将我的非 ARC 代码转换为 ARC 格式。我已经按照一些步骤将我的代码转换为 ARC 格式,但不知何故我没有成功。

我按照以下步骤将代码转换为 ARC:

1. “Preferences” -> “General” -> check “continue building after error”.   This step is fundamental to avoid an huge waste of time repeating the next steps every time an error is encountered!
2. “Edit” -> “Refactor” -> “Convert to Objective-C ARC”
3. “Select targets to convert” (check them)
4. Click “precheck” – “Cannot Convert to Objective-C ARC” (Xcode found N issues that prevent conversion from proceeding. Fix all ARC readiness issues and try again.)  You will see this message at least once, because your code contains calls that are forbidden by ARC.
5. Fix them using suggestions (click on errors to open the popup containing the tip). Then repeat from step 1.
6. “Convert to automatic reference counting” window will appear (once issues have been fixed)
7. Click next
8. Review automatic changes

我的项目的所有 HEADER 文件中仍然出现关于 @property 和 @synthesize 的错误。我必须手动完成所有 HEADER 文件中的所有更改,而不是通过自动执行上述步骤来实现。

请帮助我,如果您对此有任何适当的解决方案,请告诉我。

谢谢,

Nilesh M. Prajapati

【问题讨论】:

【参考方案1】:

XCode 无法自动修复这些错误。因此,您只需在继续之前手动修复它们。

【讨论】:

我修复了所有出现在 .m 文件中的问题,但据我所知,它应该会自动更改语法。

以上是关于使用 XCode 5.0.2 将问题从非 ARC 迁移到 ARC的主要内容,如果未能解决你的问题,请参考以下文章

XCode 4.6 中的 Mogenerator 和 ARC

如何在 xcode 中将启用 ARC 的 .a 文件添加到非 ARC 项目

iCarousel 类不适用于 xcode 4.2 和 mac os 10.6 上的 ARC

使用 arc4random 生成随机数以添加到字符串以进行 UI 测试登录 xcode UI 测试

如何以编程方式为非 ARC xcode 项目中的特定文件启用 ARC?

systemSound 不再适用于使用 ARC 升级的 Xcode 4.5.2