When I create a new file in my project in the file header, I find this:
//
// NameFile.swift
// NameProject
//
// Created by Name Surname on dd/mm/yy.
//
I would like to change it, but in the settings I don’t find where to do it.
I would like to change it for all possible future projects.
I would like to achieve such a thing.
//
// NameFile.swift
// NameProject
//
//
Edit:
I would like to try to remove the comment, but I can’t find solutions.
2
Answers
Say you want to modify (or get rid of) the XCode Header comment.
IDETemplateMacros.plist
Open as source code
. Xcode will show us the property file as text. Property files are really just XML files.On the root dict we have added an entry with key FILEHEADER and a two-lines string as a value:
Save the file IDETemplateMacros.plist on the folder:
That’s it, now when creating a new project called MyProject the header will be:
Note1. There is a list of macros on https://help.apple.com/xcode/mac/9.0/index.html?localePath=en.lproj#/dev7fe737ce0
Note 2. As an example you can write:
Note that there is a leading space but you do not include the // for the comment on the first line.
Note 3. For a more list of options see:
https://useyourloaf.com/blog/changing-xcode-header-comment/
From https://developer.apple.com/forums/thread/711305?answerId=722311022#722311022
Add
~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist
with an emptyFILEHEADER
entry to generate an empty comment.Xcode help:
https://help.apple.com/xcode/mac/?localePath=en.lproj#/dev91a7a31fc
https://help.apple.com/xcode/mac/index.html?localePath=en.lproj#/dev7fe737ce0
If you really want to remove that empty comment line then you will need to start adding custom file templates. eg for a
No Comment Swift File
template create the following:~/Library/Developer/Xcode/Templates/File Templates/MultiPlatform/Source/No Comment Swift File.xctemplate/___FILEBASENAME___.swift
withimport Foundation
followed by an empty line
~/Library/Developer/Xcode/Templates/File Templates/MultiPlatform/Source/No Comment Swift File.xctemplate/TemplateInfo.plist
with something likeTemplateInfo.plist
The default empty Swift File template in the Xcode 14 beta is:
/Applications/Xcode-beta.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source/Swift File.xctemplate/
(do not edit this directly).