Each time a new file is added in Xcode a header is added to the top. This is a good place to put a license or copywrite message. Xcode does support templates which are covered below. Placing a file named IDETemplateMacros.plist
at one of the paths listed below with the contents which include FILEHEADER
.
The string value can also include placeholders covered by Text macros reference with some listed below. Wrap each text macro with 3 underscores to include them in the output.
FILENAME
DATE
YEAR
ORGANIZATIONNAME
PACKAGENAME
PACKAGENAMEASIDENTIFIER
PRODUCTNAME
PROJECTNAME
WORKSPACENAME
The sample IDETemplateMacros.plist
included with this gist shows that a value for the text macro can be set, such as ORGANIZATIONNAME
. Newly created files in any Swift packages or Xcode projects in this workspace will inherit this file header template and will be used if another template is defined.
Below are the docs from Apple which and are copied here in case they are ever removed as others have been.
- A plist named IDETemplateMacros.plist at an appropriate location.
- An entry in IDETemplateMacros.plist for the text macro.
Xcode looks for the value of a text macro in the following locations and uses the first matching macro:
Project user data: <ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
Project shared data: <ProjectName>.xcodeproj/xcshareddata/IDETemplateMacros.plist
Workspace user data: <WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
Workspace shared data: <WorkspaceName>.xcworkspace/xcshareddata/IDETemplateMacros.plist
User Xcode data: ~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist