How does Xcode know who the project was "created by"?

Viewed 15654

Whenever a new file is added to the project, Xcode adds the following lines of comments on top.

//  Created by {my name here} on 8/4/11.
//  Copyright 2011 __{my company name here}__. All rights reserved.

How does it know what my name is? Does it assume that if my account name belongs to "Mike", "Mike" is the name of the developer writing this code?

Does it then look at Address Book trying to find out what company "Mike" works at? It would make sense, however company listed as part of my address book is not what shows up in the Xcode file.

Can one set the following up in some place where Xcode will read it from?

  • Name
  • Company name
  • some other text describing something important
6 Answers

The "Created by" name does not come from the Address Book, rather, it comes from the name in System Preferences -> User and Groups under "Current User". You can change this name and other variables in the file header by creating a property list file called IDETemplateMacros.plist. To change the name by where it says "Created by", create a new key called FULLUSERNAME and give it the value you wanted. To change the company name, create a new key called ORGANIZATIONNAME. You could also rewrite the whole header by creating a new key called FILEHEADER. To access macros like FULLUSERNAME and ORGANIZATIONNAME in the values for any of these keys, just surround the macro by two underscores on both ends. (Example: Key: FILEHEADER, Value: Made by __FULLUSERNAME__)

For where to put the plist file, refer to step 3 from Ole Begemann's blog post about macros,

Copy the file to one of the following locations. The directory specifies in which context the customized text macros should be applied:

  • For a single project and user: .xcodeproj/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist

  • For all team members in a single project: .xcodeproj/xcshareddata/IDETemplateMacros.plist

  • For all projects in a workspace for a single user: .xcworkspace/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist

  • For all projects in a workspace for all team members: .xcworkspace/xcshareddata/IDETemplateMacros.plist

  • For everything you work on, regardless of project: ~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist

For more information, check out this great article written by Ole Begemann, https://oleb.net/blog/2017/07/xcode-9-text-macros/

Related