iOS 4 真的支持 ARC 吗?iOS 4.2 SDK 在链接时缺少与 ARC 相关的符号 [英] Is ARC really supported in iOS 4? The iOS 4.2 SDK is missing ARC-related symbols at linking time

查看:6
本文介绍了iOS 4 真的支持 ARC 吗?iOS 4.2 SDK 在链接时缺少与 ARC 相关的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从 ARC 首次宣布它是一个编译时的东西并且将与 iOS 4 向后兼容以来,我已经阅读和听说过.我已经使用 Xcode 4.2 的自动重构成功地将我的项目重构为 ARC,以及何时针对 iOS 5.0 SDK 编译,它工作正常.但是,如果我尝试针对我的 iOS 4.2 SDK 进行编译,它会在链接时失败,缺少以下符号:

I've read and heard since ARC was first announced that it was a compile-time thing and would be backwards-compatible with iOS 4. I have successfully refactored my project to ARC using Xcode 4.2's automatic refactoring, and when compiled against the iOS 5.0 SDK, it works fine. However, if I try to compile against my iOS 4.2 SDK, it fails at link time, missing the following symbols:

  • _objc_retainAutoreleaseReturnValue
  • _objc_autoreleaseReturnValue
  • _objc_storeStrong
  • _objc_retain
  • _objc_release
  • _objc_retainAutoreleasedReturnValue

我查了一下,这些符号在 5.0 中存在,但在 4.2 中没有:

I checked, and these symbols are present in 5.0 but not 4.2:

iPhoneOS5.0.sdk/usr/lib $ find . -type f|xargs nm|grep -i _objc_retain$
00005ed0 T _objc_retain
000061d0 T _objc_retain

iPhoneOS4.2.sdk/usr/lib $ find . -type f|xargs nm|grep -i _objc_retain$
[... *crickets* ...]

这是否意味着苹果在撒谎?相反,我假设我很困惑并且做错了什么,但我不知道是什么.

Does this mean that Apple lied? I assume instead that I'm confused and doing something wrong, but I can't figure out what.

这是 Xcode 4.2(Build 4C199)的 GM 版本

This is with the GM release of Xcode 4.2 (Build 4C199)

推荐答案

iOS 4.3 及以上版本支持ARC.您需要使用 iOS 5.x SDK,但可以选择 iOS 4.3 作为部署目标.4.x 中不支持的一件事是自动弱引用归零.

ARC is supported on iOS 4.3 and above. You need to use the iOS 5.x SDK but can select iOS 4.3 for the Deployment Target. The one thing that is not supported in 4.x is automatic weak reference zeroing.

查看 Apple 的文档此处了解目标-C 功能可用性指数.

See Apple's documentation here for the Objective-C Feature Availability Index.

Xcode 4.4 和 4.5 可用于提交应用程序.

Xcode 4.4 and 4.5 can be used to submit apps.

请注意,NSDictionary 和 NSArray 下标部署回 OS X 10.6 和 iOS 4,请务必将部署目标也设置回.

Note that NSDictionary and NSArray subscripting deploys back to OS X 10.6 and iOS 4, be sure to set the deployment target back as well.

这篇关于iOS 4 真的支持 ARC 吗?iOS 4.2 SDK 在链接时缺少与 ARC 相关的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆