Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iqiancheng/4b5602b78f48dedae33ac3d5f3fb7a91 to your computer and use it in GitHub Desktop.
Save iqiancheng/4b5602b78f48dedae33ac3d5f3fb7a91 to your computer and use it in GitHub Desktop.

Customizing the 'Created by' Author Name in Xcode

When you create a new file in Xcode, the IDE automatically adds a header comment that includes information like the filename, creation date, and author. By default, the author name is derived from your macOS system's full username. However, you might want to customize this for various reasons - perhaps you're sharing code publicly, working on a team project, or simply prefer a different name format.

This article explains multiple methods to customize the "Created by" author name in Xcode.

Understanding the File Header Template

When you create a new file in Xcode, you'll see a header comment like this:

//
//  ViewController.swift
//  MyApp
//
//  Created by John Smith on 3/11/2025.
//

The Created by value is populated from a template macro named ___FULLUSERNAME___, which by default pulls your system's full user name.

Method 1: Using defaults Command (Recommended)

The easiest and most maintainable way to customize your author name is using the macOS defaults command to modify Xcode's template macros.

Setting a Custom Author Name

# Create the UserData directory if it doesn't exist
mkdir -p ~/Library/Developer/Xcode/UserData/

# Set the custom author name
defaults write ~/Library/Developer/Xcode/UserData/IDETemplateMacros FULLUSERNAME "John Developer"

Verifying the Configuration

You can confirm the change was applied by reading the values:

# Read the current settings
defaults read ~/Library/Developer/Xcode/UserData/IDETemplateMacros

# Expected output:
# {
#     FULLUSERNAME = "John Developer";
# }

Resetting to Default

If you want to revert to using your system username:

# Remove the custom setting
defaults delete ~/Library/Developer/Xcode/UserData/IDETemplateMacros FULLUSERNAME

Method 2: Creating a Custom Template Macros File

You can also manually create or edit the template macros plist file:

# Create the plist file with proper XML structure
cat > ~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist << EOF
<?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>FULLUSERNAME</key>
    <string>John Developer</string>
</dict>
</plist>
EOF

Method 3: Customizing Additional Template Values

Xcode uses several macros in its templates. You can customize multiple values at once:

# Set multiple template values
defaults write ~/Library/Developer/Xcode/UserData/IDETemplateMacros << EOF
{
    FULLUSERNAME = "John Developer";
    ORGANIZATIONNAME = "Awesome Company";
    COPYRIGHT = "Copyright © 2025 John Developer. All rights reserved.";
}
EOF

Method 4: Project-Specific Author Settings

You can also set project-specific author information:

# Create a project-specific template macros file
mkdir -p /path/to/YourProject.xcodeproj/xcuserdata/$(whoami).xcuserdatad/

cat > /path/to/YourProject.xcodeproj/xcuserdata/$(whoami).xcuserdatad/IDETemplateMacros.plist << EOF
<?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>FULLUSERNAME</key>
    <string>Project Author</string>
</dict>
</plist>
EOF

Template Macros Precedence

Xcode looks for template macros in the following order:

  1. Project-level: <YourProject>.xcodeproj/xcuserdata/<username>.xcuserdatad/IDETemplateMacros.plist
  2. User-level: ~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist
  3. Global-level: /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/IDETemplateMacros.plist

The more specific (project-level) settings will override the more general ones.

Modifying Global Xcode Settings (Not Recommended)

While it's possible to modify the global Xcode settings using:

# Not recommended - changes may be lost during Xcode updates
sudo defaults write com.apple.dt.Xcode PBXCustomTemplateMacroDefinitions '{"FULLUSERNAME" = "John Developer";}'

This method is not recommended as your changes might be lost during Xcode updates.

Troubleshooting

If your changes don't take effect immediately:

# Force quit Xcode
killall Xcode

# Clear Xcode caches
rm -rf ~/Library/Developer/Xcode/DerivedData/
rm -rf ~/Library/Caches/com.apple.dt.Xcode/

Conclusion

Using the defaults command to modify ~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist is the most reliable way to customize your Xcode author name. It survives Xcode updates and doesn't require modifying system settings or Xcode's internal templates.

Remember to restart Xcode after making these changes for them to take effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment