Add new templates in Xcode

2019-02-09 04:46发布

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

7条回答
Summer. ? 凉城
2楼-- · 2019-02-09 05:33

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.

查看更多
甜甜的少女心
3楼-- · 2019-02-09 05:34

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.

查看更多
▲ chillily
4楼-- · 2019-02-09 05:35

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.

查看更多
神经病院院长
5楼-- · 2019-02-09 05:49

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.

查看更多
Lonely孤独者°
6楼-- · 2019-02-09 05:49

I had taken reference from this link, its really helpful having some correction in benny answer which I mentioned in comment

How to create project templates in Xcode 4

查看更多
Animai°情兽
7楼-- · 2019-02-09 05:50

You can use this template which is a well researched one available in the market.

http://www.binpress.com/app/ios-boilerplate-and-template/1597

查看更多
登录 后发表回答