问题
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