我们正在尝试制作一个项目模板,但是关于此的文档很少见或不存在。Xcode Project Template对文件内容没有进行替换的具体帮助
对一些模板文件做一些逆向工程,我们想出了以下内容。但是,它实际上并没有工作!
首先,我们已经找到了该项目模板应该往里装:
〜/库/ Application Support /开发/共享/ Xcode中/工程模板
我们已经取得了项目并安装它在这里,这部分工作 - 我们看到这个显示在Xcode“New Project”选择器的“用户模板”部分。
项目文件夹包含以下文件。正如你所看到的,我希望文件名被取消(该部分起作用),但正如你将看到的,我还希望替换文件的内容;这不会发生。
- ___ PROJECTNAME ___。xcodeproj
- ___ PROJECTNAMEASIDENTIFIER ____ Prefix.pch
- ___ PROJECTNAMEASIDENTIFIER ___。ICNS
- ___ PROJECTNAMEASIDENTIFIER ___ Delegate.h
- ___ PROJECTNAMEASIDENTIFIER ___ Delegate.m
- ___ PROJECTNAMEASIDENTIFIER ___ Template.html
- Debug.xcconfig
- en.lproj
- 的Info.plist
- Release.xcconfig
我已经把两个特殊的文件到___ ___ PROJECTNAME包xcodeproj:
- TemplateInfo.plist
- TemplateIcon。 icns - 显示在新建项目窗口中的图标
如果我创建一个新的项目中使用这个模板(称为“富&酒吧”作为一个压力测试),这些都是文件,它创建:
- Debug.xcconfig
- en.lproj
- 富& Bar.xcodeproj
- 富___ Bar_Prefix.pch
- 富___ Bar.icns
- 富___ BarDelegate.h
- 富___ BarDelegate.m
- Foo ___ BarTemplate.html
- Info.plist
- Release。xcconfig
到目前为止好!
但看着文件内容,我得到这样的事情。这里是富___ BarDelegate.m的内容:
//
// «PROJECTNAMEASIDENTIFIER»Delegate.m
// «PROJECTNAME»
//
// Created by «FULLUSERNAME» on «DATE».
// Copyright «ORGANIZATIONNAME» «YEAR» . All rights reserved.
//
#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>
丹伍德,当你继续发现他们时,请在这个问题上追加你自己的未来技巧。你发布这个问题重新启发了我自己尝试这个,我很想听听你最终得出的结论。 – pestophagous 2008-10-06 22:41:24