自定义xcode模板能否部分或有选择地启用ARC(自动引用计数)? [英] Can a custom xcode template partially and selectively enable ARC (Automatic Reference Counting)?

查看:100
本文介绍了自定义xcode模板能否部分或有选择地启用ARC(自动引用计数)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我使用的库不支持ARC(自动引用计数).

Problem: A library I use won't support ARC (Automatic Reference Counting).

背景(针对不熟悉ARC的用户): http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html

Background (for those unfamiliar to ARC): http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html

手动解决方案:为该库的每个实现文件添加-fno-objc-arc选项,否则通常在我的应用程序代码中使用ARC.

Manual Solution: Add the -fno-objc-arc option for each implementation file of the library, and otherwise use ARC normally in my application code.

观察:可以复制以下模板文件,并且很可能将其完全打开或关闭ARC(无需在上面添加编译器标志,这是我需要的中间解决方案):

Observation: The following template file can be copied and most likely be used to either turn ARC completely ON or OFF (without adding the compiler flags above -- the in-between solution that I need):

"/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS参考Counting.xctemplate"

"/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS Reference Counting.xctemplate"

问题重述:有什么方法可以避免手动解决? (在-fno-objc-arc选项中复制和粘贴超过100次是不便的.我希望苹果提供一种编程解决方案.由于Xcode UI很有可能会发生变化,因此我不希望使用Automator.app进行复制/粘贴. )

Question Restatement: Is there a way to avoid the manual solution? (Copy and Pasting in the -fno-objc-arc option over 100 times is inconvenient. I hope Apple exposes a programmatic solution. I would not want to use Automator.app to do the copy/pasting since the Xcode UI will very likely change.)

示例Xcode4模板生成器: https://github .com/MrGando/Xcode-4-Template-Generator/blob/master/template_generator.py

Example Xcode4 template Generator: https://github.com/MrGando/Xcode-4-Template-Generator/blob/master/template_generator.py

请注意template_generator.py具有实验性的共享版本设置.我要有选择地共享(部分共享)设置.另外,可能希望通过宏替换或通过提供第二个main.m文件将main()中的NSAutoreleasePool更改为@autorelease块.

Note template_generator.py has experimental Shared Build Settings. I want selectively shared (partially shared) settings. In addition it would be desirable to change the NSAutoreleasePool in main() to an @autorelease block, either with a macro substitution, or by providing a 2nd main.m file.

推荐答案

否,但是您很难做到这一点...只需为这些MRC源创建一个静态库目标(如果尚不存在, (这是第3方库),然后为每个目标设置适当的构建设置.然后将该库与您的最终可执行文件链接.

no, but you're doing it the hard way... simply create a static library target for these MRC sources (if one does not already exist -- it is a 3rd party library), then set the appropriate build settings per target. then link the library with your final executable.

这篇关于自定义xcode模板能否部分或有选择地启用ARC(自动引用计数)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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