Add new templates in Xcode
Asked Answered
O

5

16

How to add new templates in Xcode for iPhone application developement?

Odie answered 26/2, 2009 at 9:16 Comment(0)
H
12

For some advices, I suggest to take a look at answers to a related question: Change templates in Xcode.

In particular, if you want your modifications not to be lost whenever you upgrade Xcode, put your templates in ~/Library/Developer/Shared/Xcode, not under /Developer.

Hospitium answered 26/2, 2009 at 11:34 Comment(1)
It does seem to be ~/Library/Developer/Xcode nowadays. At least I do not have a Shared folder inside of ~/Library/DeveloperMagruder
E
6

From my answer to this question:

XCode uses template files for file and project templates and does variable expansion in both at creation time.

XCode 3.0-3.1 templates can be found in [Dev Installation]/Library/Xcode/, likely /Developer/Library/XCode. If you want to modify these templates or add your own, use the following directories to save your new/modified templates so that they are not wiped out by future Developer Tool upgrades:

  • File templates: ~/Library/Developer/Shared/Xcode/File Templates/
  • Target templates: ~/Library/Developer/Shared/Xcode/Target Templates/
  • Project templates: ~/Library/Developer/Shared/Xcode/Project Templates/

I think that you can also use the /Library/Developer/Shared/Xcode/[File|Target|Project] Templates/ directory for templates shared by all users.

A good tutorial on writing file templates is here [MacResearch.org].

Enlace answered 26/2, 2009 at 20:41 Comment(0)
P
3

You can make a template through changing the contents of the developer folder. I have done this myself. Let's say, you were making an html template: Step 1. Go to:/Developer/Library/Xcode/Templates/file templates/resource Step 2. make a folder there called HTML File.xctemplate. Step 3. Copy the contents of the RTF file folder Step 4. Paste the contents in your html folder. Step 5. Change the rtf extention of the

___FILEBASENAME___.rtf(in your html folder) to .html

Step 6. Change the plist file to:

Key                       |         Type   |     Value
DefaultCompletionName            String          File
Description                      String         An empty Hyper Text Markup language (HTML) file.
Kind                             String         Xcode.IDEKit.TextSubstitutionFileTemplateKind
MainTemplateFile                 String         ___FILEBASENAME___.html
Name                             String         Hyper Text Markup Language file
Summary                          String         An empty Hyper Text Markup Language (HTML) file

Step 7. now, when you add a new file, if you go to resources, you will find an html template. PS You just need to replace the html text to your choice, such as ruby.

Platinotype answered 11/10, 2011 at 21:16 Comment(0)
L
2

XCode 4 changes how templates work, and where templates go, so be careful following instructions unless they refer to XCode 4. You can find a few template examples, and the paths to where they go in my XCode4 customization repository:

https://github.com/KiGi/XCode4Customization

The paths where the system templates live is:

/Developer/Platforms/iPhoneOS.platform/Developer/Library/ Xcode/Templates/File Templates

Don't change those, copy and modify in your own library directory:

~/Library/Developer/Xcode/UserData/File Templates

Those paths are also in the "WhereToPlaceFiles" RTF file on github.

Leap answered 11/10, 2011 at 21:48 Comment(0)
O
0

I wrote an article on how to create a new Xcode template from an existing project here.

It covers:

  • specifying your project files are relative to the project path
  • using the commandline to search / replace & fiddle file permissions
  • excluding info.plist from the target membership
  • giving your template an icon

It doesn't cover where to put the template. That information is covered in other answers.

Osmo answered 19/9, 2010 at 1:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.