How to add “Class Prefix” field while creating xco

2019-07-25 10:33发布

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条回答
Summer. ? 凉城
2楼-- · 2019-07-25 11:14

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

查看更多
登录 后发表回答