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

Viewed 140

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!

1 Answers
  1. create a file named IDETemplateMacros.plist. The content for this new file 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___
//  Your Package Name
// 
//  Created by ___FULLUSERNAME___ on ___DATE___.
//  Copyright © 2021 Your Name Or Company. All rights reserved.
//</string>
</dict>
</plist>
  1. put this file in the following location,
<Your Package Root>/.swiftpm/xcode/package.xcworkspace/xcuserdata/userName.xcuserdatad/IDETemplateMacros.plist

Note: you should right click 'show package content' of the package.xcworkspace to get inside screen shot

Related