Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecific help with Xcode Project Template that is not doing substitution in file contents
    primarykey
    data
    text
    <p>We are trying to make a project template, but the documentation on this is spotty or non-existent.</p> <p>Doing some reverse-engineering on some template files, we have come up with the following. However, it doen't actually work!</p> <p>First of all, we have figured out that project templates should be installed inside:</p> <p>~/Library/Application Support/Developer/Shared/Xcode/Project Templates</p> <p>We have made project and installed it here, and this part works - we see this show up in the "User Templates" section of the Xcode "New Project" chooser.</p> <p>The project folder contains the following files. As you can see, I want the file names to be subsituted (that part works) but as you will see, I also want the contents of the files to be substituted; this doesn't happen.</p> <ul> <li>___PROJECTNAME___.xcodeproj </li> <li>___PROJECTNAMEASIDENTIFIER____Prefix.pch </li> <li>___PROJECTNAMEASIDENTIFIER___.icns </li> <li>___PROJECTNAMEASIDENTIFIER___Delegate.h </li> <li>___PROJECTNAMEASIDENTIFIER___Delegate.m </li> <li>___PROJECTNAMEASIDENTIFIER___Template.html </li> <li>Debug.xcconfig </li> <li>en.lproj </li> <li>Info.plist </li> <li>Release.xcconfig </li> </ul> <p>I have put in two special files into the ___PROJECTNAME___.xcodeproj package:</p> <ul> <li>TemplateInfo.plist </li> <li>TemplateIcon.icns - the icon to show up in the New Project window</li> </ul> <p>If I create a new project (called "Foo &amp; Bar" as a stress test) using this template, these are the files it creates:</p> <ul> <li>Debug.xcconfig</li> <li>en.lproj</li> <li>Foo &amp; Bar.xcodeproj</li> <li>Foo___Bar_Prefix.pch</li> <li>Foo___Bar.icns</li> <li>Foo___BarDelegate.h</li> <li>Foo___BarDelegate.m</li> <li>Foo___BarTemplate.html</li> <li>Info.plist</li> <li>Release.xcconfig</li> </ul> <p>So far so good! </p> <p>But looking in the file contents, I get things like this. Here is the contents of Foo___BarDelegate.m:</p> <pre><code>// // «PROJECTNAMEASIDENTIFIER»Delegate.m // «PROJECTNAME» // // Created by «FULLUSERNAME» on «DATE». // Copyright «ORGANIZATIONNAME» «YEAR» . All rights reserved. // #import "«PROJECTNAMEASIDENTIFIER»Delegate.h" @implementation «PROJECTNAMEASIDENTIFIER»Delegate @end </code></pre> <p>The apparent issue is that somehow I'm doing the TemplateInfo.plist wrong. But then again, notice how not only are my special items not being substitued, but the standard items don't even get replaced! So maybe it's a deeper issue.</p> <p>But with a problematic TemplateInfo.plist being my best hypothesis, I present a couple of variations I have tried. Neither work.</p> <p>Either:</p> <pre><code>{ 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."; } </code></pre> <p>or:</p> <pre><code>{ 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."; } </code></pre> <p><strong>Update</strong>: I've also tried adding the "FilesToRename" key, even though the ___ seems to be automatically causing renaming to happen. This is the plist contents with that in, in XML format (since some people were worried about that UTF-8 nature of things -- yes, it's a valid plist):</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;Description&lt;/key&gt; &lt;string&gt;This project builds a cocoa-based "element" plugin for Sandvox.&lt;/string&gt; &lt;key&gt;FilesToMacroExpand&lt;/key&gt; &lt;array&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER»_Prefix.pch&lt;/string&gt; &lt;string&gt;en.lproj/InfoPlist.strings&lt;/string&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER».icns&lt;/string&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER»Delegate.h&lt;/string&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER»Delegate.m&lt;/string&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER»Template.html&lt;/string&gt; &lt;string&gt;Info.plist&lt;/string&gt; &lt;/array&gt; &lt;key&gt;FilesToRename&lt;/key&gt; &lt;dict&gt; &lt;key&gt;___PROJECTNAMEASIDENTIFIER___.icns&lt;/key&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER».icns&lt;/string&gt; &lt;key&gt;___PROJECTNAMEASIDENTIFIER___Delegate.h&lt;/key&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER»Delegate.h&lt;/string&gt; &lt;key&gt;___PROJECTNAMEASIDENTIFIER___Delegate.m&lt;/key&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER»Delegate.m&lt;/string&gt; &lt;key&gt;___PROJECTNAMEASIDENTIFIER___Template.html&lt;/key&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER»Template.html&lt;/string&gt; &lt;key&gt;___PROJECTNAMEASIDENTIFIER____Prefix.pch&lt;/key&gt; &lt;string&gt;«PROJECTNAMEASIDENTIFIER»_Prefix.pch&lt;/string&gt; &lt;key&gt;___PROJECTNAME___.xcodeproj&lt;/key&gt; &lt;string&gt;«PROJECTNAME».xcodeproj&lt;/string&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/plist&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload