iosswiftxcodepackageswift-package

Incomplete file/copyright headers in Swift Package with Xcode 12 / 13


Is there any way to automatically add package/target name and copyright + company name to the header when creating new files while developing a swift package with Xcode 12/13?

Just create a new package (File > New > Package) and add a new file to the sources (File > New > File).

Currently gives me this:

//
//  File.swift
//  
//
//  Created by User Name on 02.10.21.
//

instead of this (like when adding files to regular Xcode project):

//
//  File.swift
//  MyPackage
//
//  Created by User Name on 02.10.21.
//  Copyright © 2021 Company Name. All rights reserved.
//

Thanks!


Solution

    1. create a file named IDETemplateMacros.plist. The content for this new file should like this,
    <?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>
    //  ___FILENAME___
    //  ___WORKSPACENAME___
    // 
    //  Created by ___FULLUSERNAME___ on ___DATE___.
    //  Copyright © 2021 Your Name Or Company. All rights reserved.
        </string>
    </dict>
    </plist>
    
    1. put this file in one of the following locations,

      a. Has an impact on files created by the specified user (username) in the current workspace:

       <Your Package Root>/.swiftpm/xcode/package.xcworkspace/xcuserdata/<Your username>.xcuserdatad/IDETemplateMacros.plist
      

      b. Affects files created by all members in the current workspace:

      <Your Package Root>/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDETemplateMacros.plist
      

    Note:

    Update: