How to customize Xcode Template like raywenderlich project did

how can i custom Xcode file template like " Text Kit Tutorial: Getting Started" project, when i open the project and create a file,header contains text like below:

/// Copyright © 2018 Razeware LLC

///

/// Permission is hereby granted, free of charge, to any person obtaining a copy

/// of this software and associated documentation files (the “Software”), to deal

/// in the Software without restriction, including without limitation the rights

/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

/// copies of the Software, and to permit persons to whom the Software is

/// furnished to do so, subject to the following conditions:

///

/// The above copyright notice and this permission notice shall be included in

/// all copies or substantial portions of the Software.

///

/// Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,

/// distribute, sublicense, create a derivative work, and/or sell copies of the

/// Software in any work that is designed, intended, or marketed for pedagogical or

/// instructional purposes related to programming, coding, application development,

/// or information technology. Permission for such use, copying, modification,

/// merger, publication, distribution, sublicensing, creation of derivative works,

/// or sale is expressly withheld.

///

/// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

/// THE SOFTWARE.

i think this is a file template but i don’t know how to customize, so can anybody help me? thanks a lot!

Here are a few articles that show how to create custom templates.

Have fun!

thank you for your reply, but the project i downloaded from raywenerlich, my xcode didn’t have any custom templates, when i create a file copyright it automatically generates . the project copy to another pc also the same, so i guess it is the project setting not the xcode setting, but i don’t know it…

The templates aren’t tied to a particular project. The files for a given template are stored in a folder with an extension of .xctemplate. The templates that come with Xcode can be found starting in:

/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates

From there you’ll see folders for “File Templates” and “Project Templates”. In the “File Templates” folder, you’ll see folders for the various template groups (Source, User Interface, Core Data, etc). In each of those folders, you’ll see the .xctemplate folders.

Each .xctemplate folder contains PNG files (for the icon in the “Choose a template for your new file” dialog), a PLIST file, and a source file.

Your custom templates will be stored in:

~/Library/Developer/Xcode/Templates

Any folders there will be treated as template groups. Then those group folders will contain the .xctemplate folders.

As discussed in the articles I referenced, the easiest way to create a custom template is to copy an existing built-in Xcode template to the custom templates folder. Once there, you can tweak the source to be whatever you want.

Hope that helps!

This topic was automatically closed after 166 days. New replies are no longer allowed.