Changing the default header comment license in Xcode

后端 未结 11 1954
难免孤独
难免孤独 2020-12-04 08:05

Whenever I create a new .cpp/.h file in Xcode a comment is added to the top of the file. For example:

/*
 *  .cpp
 *  
 *
         


        
相关标签:
11条回答
  • 2020-12-04 08:18

    Try modifying this file:

    /Developer/Library/Xcode/File\ Templates/C\ and\ C++/Header\ File.pbfiletemplate/header.h
    
    0 讨论(0)
  • 2020-12-04 08:22

    Don't edit anything in /Developer as Apple can overwrite this at any time.

    The following works for Xcode 4, 5 and 6 except later source differs and is under /Applications

    Instead copy the templates that you want to change from /Applications/Xcode<version>.app/Contents/Developer/Library/Xcode/Templates to ~/Library/Developer/Xcode/Templates/File Templates and then edit the files keeping the same directory structure but edit the directory name that is the template to not show up a a duplicate in Xcode.

    e.g for a new category of C/C+ files in Xcode 5 copy /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/C and C++ to ~/Library/Developer/Xcode/Templates/File Templates/GPL C and C++

    this process is copied from Red Glasses's blog

    For Xcode 4 the source path is or for Xcode 4 /Developer/Library/Xcode/Templates/File Templates

    0 讨论(0)
  • 2020-12-04 08:26
    /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates
    

    any update of your SDK will wipe changes here so keep your template backed up somewhere else

    0 讨论(0)
  • 2020-12-04 08:27

    This blog post has some good steps for modifying file templates in Xcode 4.3:

    http://error-success.piku.org.uk/2012/04/27/how-to-make-xcode-4-3-2-templates/

    The /Developer folder no longer exists, so you copy the templates from within the Xcode.app bundle located in /Applications:

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

    And place your modified copy here, as before:

    ~/Library/Developer/Xcode/Templates/File\ Templates/

    UPDATE: I decided to write a script that would extract the built in Xcode templates and replace the headers. Source and instructions can be found at the following url:

    https://github.com/royclarkson/xcode-templates

    0 讨论(0)
  • 2020-12-04 08:27

    For AppCode users:

    1. Go to preferences (CMD + ,)
    2. Editor-File and Code Templates
    3. Change Scheme to Project
    4. Modify Files and/or Includes as you need.
    5. add to git .idea/fileTemplates if needed
    0 讨论(0)
  • 2020-12-04 08:28

    In Xcode 4.2, they're here:

    /Developer/Library/Xcode/Templates/File Templates
    
    0 讨论(0)
提交回复
热议问题