Can a custom xcode template partially and selectively enable ARC (Automatic Reference Counting)?

别等时光非礼了梦想. 提交于 2019-12-21 22:20:48

问题


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

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

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

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 Reference Counting.xctemplate"

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.)

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

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.


回答1:


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.




回答2:


You can select multiple files in the Compile Sources list and apply the -fno-objc-arc tag to all of them at once by pressing Enter > Paste > Enter.



来源:https://stackoverflow.com/questions/8691921/can-a-custom-xcode-template-partially-and-selectively-enable-arc-automatic-refe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!