在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

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

问题描述

自从ARC首次宣布它是编译时的东西并且将向后兼容iOS 4以来,我已经阅读和听过。我已经使用Xcode 4.2的自动重构成功地将我的项目重构为AR​​C,并且针对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

  • _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* ...]

这是否意味着Apple撒谎?相反,我认为我很困惑,做错了什么,但我无法弄清楚是什么。

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)

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的文档这里

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天全站免登陆