We are trying to create a project template, but the documentation on it is spotty or non-existent.
Performing some reverse engineering in some template files, we came to the following: However, this actually does not work!
First of all, we found out that project templates should be installed inside:
~ / Library / Application Support / Developer / Shared / Xcode / Project Templates
We created the project and installed it here, and this part works - we see that it is shown in the "Custom Templates" section in the Xcode New Project editor.
The project folder contains the following files. As you can see, I want the file names to be replaced (this part works), but, as you will see, I also want the contents of the files to be replaced; this does not happen.
- ___ PROJECTNAME ___. xcodeproj
- ___ PROJECTNAMEASIDENTIFIER ____ Prefix.pch
- ___ PROJECTNAMEASIDENTIFIER ___. icns
- ___ PROJECTNAMEASIDENTIFIER ___ Delegate.h
- ___ PROJECTNAMEASIDENTIFIER ___ Delegate.m
- ___ PROJECTNAMEASIDENTIFIER ___ Template.html
- Debug.xcconfig
- ru.lproj
- Info.plist
- Release.xcconfig
I put two special files in the package ___ PROJECTNAME ___. xcodeproj:
- TemplateInfo.plist
- TemplateIcon.icns - the icon displayed in the "New Project" window
If I create a new project (called "Foo and Bar" as a stress test) using this template, these are the files that it creates:
- Debug.xcconfig
- en.lproj
- Foo and Bar.xcodeproj
- Foo ___ Bar_Prefix.pch
- Foo ___ Bar.icns
- Foo ___ BarDelegate.h
- Foo ___ BarDelegate.m
- Foo ___ BarTemplate.html
- Info.plist
- Release.xcconfig
!
, . Foo ___ BarDelegate.m:
#import "«PROJECTNAMEASIDENTIFIER»Delegate.h"
@implementation «PROJECTNAMEASIDENTIFIER»Delegate
@end
, - TemplateInfo.plist. , , ! , , .
TemplateInfo.plist, , , . .
:
{
FilesToMacroExpand = (
"\_\_\_PROJECTNAMEASIDENTIFIER\_\_\_\_Prefix.pch",
"en.lproj/InfoPlist.strings",
"\_\_\_PROJECTNAMEASIDENTIFIER\_\_\_\_Prefix.pch",
"\_\_\_PROJECTNAMEASIDENTIFIER\_\_\_.icns",
"\_\_\_PROJECTNAMEASIDENTIFIER\_\_\_Delegate.h",
"\_\_\_PROJECTNAMEASIDENTIFIER\_\_\_Delegate.m",
"\_\_\_PROJECTNAMEASIDENTIFIER\_\_\_Template.html",
"Info.plist"
);
Description = "This project builds a cocoa-based \"element\" plugin for Sandvox.";
}
{
FilesToMacroExpand = (
"«PROJECTNAMEASIDENTIFIER»\_Prefix.pch",
"en.lproj/InfoPlist.strings",
"«PROJECTNAMEASIDENTIFIER»\_Prefix.pch",
"«PROJECTNAMEASIDENTIFIER».icns",
"«PROJECTNAMEASIDENTIFIER»Delegate.h",
"«PROJECTNAMEASIDENTIFIER»Delegate.m",
"«PROJECTNAMEASIDENTIFIER»Template.html",
"Info.plist"
);
Description = "This project builds a cocoa-based \"element\" plugin for Sandvox.";
}
. "FilesToRename", ___ . plist XML ( UTF-8 - , plist):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Description</key>
<string>This project builds a cocoa-based "element" plugin for Sandvox.</string>
<key>FilesToMacroExpand</key>
<array>
<string>«PROJECTNAMEASIDENTIFIER»_Prefix.pch</string>
<string>en.lproj/InfoPlist.strings</string>
<string>«PROJECTNAMEASIDENTIFIER».icns</string>
<string>«PROJECTNAMEASIDENTIFIER»Delegate.h</string>
<string>«PROJECTNAMEASIDENTIFIER»Delegate.m</string>
<string>«PROJECTNAMEASIDENTIFIER»Template.html</string>
<string>Info.plist</string>
</array>
<key>FilesToRename</key>
<dict>
<key>___PROJECTNAMEASIDENTIFIER___.icns</key>
<string>«PROJECTNAMEASIDENTIFIER».icns</string>
<key>___PROJECTNAMEASIDENTIFIER___Delegate.h</key>
<string>«PROJECTNAMEASIDENTIFIER»Delegate.h</string>
<key>___PROJECTNAMEASIDENTIFIER___Delegate.m</key>
<string>«PROJECTNAMEASIDENTIFIER»Delegate.m</string>
<key>___PROJECTNAMEASIDENTIFIER___Template.html</key>
<string>«PROJECTNAMEASIDENTIFIER»Template.html</string>
<key>___PROJECTNAMEASIDENTIFIER____Prefix.pch</key>
<string>«PROJECTNAMEASIDENTIFIER»_Prefix.pch</string>
<key>___PROJECTNAME___.xcodeproj</key>
<string>«PROJECTNAME».xcodeproj</string>
</dict>
</dict>
</plist>