Changing the default header comment license in Xcode

后端 未结 11 1955
难免孤独
难免孤独 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:31

    With Xcode 9 there is a built-in option which you can find in the details below.

    1. Create a property list file named IDETemplateMacros.plist
    2. Add a FILEHEADER value to the Root and set its string value with your copyright text like Copyright © 2017 ...
    3. Copy the file to one of the following locations
      • For a single project and user <ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
      • For all team members in a single project <ProjectName>.xcodeproj/xcshareddata/IDETemplateMacros.plist
      • For all projects in a workspace for a single user <WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
      • For all projects in a workspace for all team members <WorkspaceName>.xcworkspace/xcshareddata/IDETemplateMacros.plist
      • For everything you work on, regardless of project ~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist
    4. Create a new file - you should see the new copyright header

    Sample IDETemplateMacros.plist for copy and paste:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>FILEHEADER</key>
        <string>
    //  Created by Your Name on 29.12.17.
    //  Copyright © 2017 Your Company. All rights reserved.
    //  </string>
    </dict>
    </plist>
    
    0 讨论(0)
  • 2020-12-04 08:31

    It's very simple:

    1. Open up terminal
    2. In one line, write the following:

      defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions -dict ORGANIZATIONNAME "Blah, Inc"
      

    You don't have to worry about changing directories beforehand or anything else. It works instantly.

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

    Change the details in your Address Book - add a company name. It will pick it up from there.

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

    First try changing your Name and Organization your contact card in Address Book.

    If that doesn't work, open System Preferences > Users & Groups > Right click on your user (System Preferences must already be unlocked) > Advanced Options... > Change the name in the Full Name text box.

    To change the organization name in Xcode click on the project file so it is selected (left sidebar of Xcode in the Project navigator) > In the File Inspector (right sidebar of Xcode) change the Organization text box.

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

    – Press ⌘ 1 to display the File Navigator.
    – Click on the name of your project at the top of the File Navigator.
    – Press ⌘⌥⇧ ⏎ (that's Command Option Shift Return) to view the Version Editor.
    – Make sure that the Comparison View is shown(View > Version Editor > Show Comparison View).

    This lets you see the raw text of your project's project.pbxproj file.

    – Press ⌘ f to search the project.pbxproj file, paste in ORGANIZATIONNAME and press Return.

    This is where the name of the organization that follows the copyright text is defined.

    0 讨论(0)
提交回复
热议问题