简体   繁体   中英

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

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM