How to add “Class Prefix” field while creating xcode project template

淺唱寂寞╮ 提交于 2020-02-06 04:44:12

问题


I am using a custom template that was defined already by some one. When I use that template, Xcode is not asking for "Class Prefix". Because of this, what ever the classes that are created using this template are having a class name as project name followed by the class name we are giving like "SampleProjectViewController.h" or "SampleProjectViewController.m".

Is there a way to add "Class Prefix" field and use this class prefix, while creating new classes, so that when I create a new class, expected class name would be SPViewController.h or SPViewController.m ?


回答1:


Add com.apple.dt.unit.prefixable to the Ancestors, it will automatically add the dialog. Then, use ___VARIABLE_classPrefix:identifier___ as a replacement string. Eg. let's say you have a class called Foo:

@interface ___VARIABLE_classPrefix:identifier___Foo : NSObject
@end

@implementation ___VARIABLE_classPrefix:identifier___Foo
@end

Files don't need to have that long prefix, you can simply do that in your Definitions by using something like ___VARIABLE_classPrefix:identifier___Foo.m as the key and Foo.m as the Path (or however your naming works).



来源:https://stackoverflow.com/questions/16941940/how-to-add-class-prefix-field-while-creating-xcode-project-template

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