Whenever I create a new .cpp/.h file in Xcode a comment is added to the top of the file. For example:
/*
* <file>.cpp
* <Name of project>
*
* Created by <My name> on <Date>.
* Copyright <Year and company>. All rights reserved.
*
*/
I want to change the default comment to be another license, like GPL/LGPL/ or something else. Is there somewhere I can change this behavior in Xcode?
ベストアンサー1
Beginning with Xcode 9, do the following:
Create a property list file named
IDETemplateMacros.plist
.Add a
FILEHEADER
value to the root and set its string value to your copyright text (e.g.Copyright © 2017 ...
).Save the file to one of the following locations:
For a single user in a single project
<ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
For all team members in a single project
<ProjectName>.xcodeproj/xcshareddata/IDETemplateMacros.plist
For a single user in all projects in a workspace
<WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
For all users in all projects in a workspace
<WorkspaceName>.xcworkspace/xcshareddata/IDETemplateMacros.plist
For everything you work on
~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist
If you now create a new file in Xcode, you should see the new copyright header.
Here's a sample IDETemplateMacros.plist
for copying and pasting:
<?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>
Note that the closing </string>
tag should be on the last line to avoid an additional newline.