Can a custom xcode template partially and selectiv

2019-04-12 21:50发布

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.

2条回答
贼婆χ
2楼-- · 2019-04-12 22:10

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.

查看更多
再贱就再见
3楼-- · 2019-04-12 22:20

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.

查看更多
登录 后发表回答