# Swift Package Manager Project Don't Generate Filename and Boilerplates

**URL:** <https://forums.swift.org/t/swift-package-manager-project-dont-generate-filename-and-boilerplates/49625>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [June 15, 2021, 4:03am UTC](https://forums.swift.org/t/swift-package-manager-project-dont-generate-filename-and-boilerplates/49625 "2021-06-15T04:03:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jevonmao](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jevonmao/32/18113_2.png) [@jevonmao](https://forums.swift.org/u/jevonmao)\
**Post date:** [June 15, 2021, 4:03am UTC](https://forums.swift.org/t/swift-package-manager-project-dont-generate-filename-and-boilerplates/49625/1 "2021-06-15T04:03:47Z")

</div>

In a regular Xcode project app, when I right click to create a new file, it will offer me a template (eg. SwiftUI/Swift/Storyboard) to choose from. I choose a template, click on next, and the prompt will allow me to input the filename. After that, Xcode automatically generates the file with the filename given, the header filename, and the struct name in case of SwiftUI file.

However, in Swift Package Manager projects, right click to create new file don't give me the chance to input a filename and creates a default Swift or SwiftUI file with placeholder names like file.swift.

Is this a known issue or bug? Why this behavior?

---

<div class="post-metadata">

**Author:** ![bentoboxlimited](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bentoboxlimited/32/23193_2.png) [@bentoboxlimited](https://forums.swift.org/u/bentoboxlimited)\
**Post date:** [May 8, 2022, 7:28pm UTC](https://forums.swift.org/t/swift-package-manager-project-dont-generate-filename-and-boilerplates/49625/2 "2022-05-08T19:28:54Z")

</div>

Did you ever find a solution?

---

<div class="post-metadata">

**Author:** ![russellyi](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/russellyi/32/23199_2.png) [@russellyi](https://forums.swift.org/u/russellyi)\
**Post date:** [May 9, 2022, 9:12am UTC](https://forums.swift.org/t/swift-package-manager-project-dont-generate-filename-and-boilerplates/49625/3 "2022-05-09T09:12:37Z")

</div>

I solved this problem by using a custom file template. For more information on how to create a custom file template, please refer to [xcode-project-and-file-templates](https://www.raywenderlich.com/26582967-xcode-project-and-file-templates). The template contains two files ` ___FILEBASENAME___.swift` and `TemplateInfo.plist`.

` ___FILEBASENAME___.swift` for the following.

```swift
// ___FILEHEADER___

import Foundation

```

`TemplateInfo.plist` for the following.

```swift
<?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>SupportsSwiftPackage</key>
	<true/>
	<key>Kind</key>
	<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
	<key>Description</key>
	<string>An empty Swift file for package.</string>
	<key>Summary</key>
	<string>An empty Swift file for package.</string>
	<key>SortOrder</key>
	<string>1</string>
	<key>Image</key>
	<dict>
		<key>FileTypeIcon</key>
		<string>swift</string>
	</dict>
	<key>AllowedTypes</key>
	<array>
		<string>public.swift-source</string>
	</array>
	<key>Platforms</key>
	<array />
	<key>DefaultCompletionName</key>
	<string>File</string>
	<key>MainTemplateFile</key>
	<string> ___FILEBASENAME___.swift</string>
	<key>Options</key>
	<array>
		<dict>
			<key>Identifier</key>
			<string>productName</string>
			<key>Required</key>
			<true/>
			<key>Name</key>
			<string>Name:</string>
			<key>Description</key>
			<string>The name of the file to create</string>
			<key>Type</key>
			<string>text</string>
			<key>NotPersisted</key>
			<true/>
		</dict>
	</array>
</dict>
</plist>

```

---

<div class="post-metadata">

**Author:** ![davidaberg](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/davidaberg/32/15812_2.png) [@davidaberg](https://forums.swift.org/u/davidaberg)\
**Post date:** [December 8, 2022, 12:56pm UTC](https://forums.swift.org/t/swift-package-manager-project-dont-generate-filename-and-boilerplates/49625/4 "2022-12-08T12:56:01Z")

</div>

Got it working with this solution by adding all suggested values in the Options dictionary.

---

<div class="post-metadata">

**Author:** ![johnliedtke](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/johnliedtke/32/22455_2.png) [@johnliedtke](https://forums.swift.org/u/johnliedtke)\
**Post date:** [February 27, 2023, 9:58pm UTC](https://forums.swift.org/t/swift-package-manager-project-dont-generate-filename-and-boilerplates/49625/5 "2023-02-27T21:58:40Z")

</div>

For others, I placed this is in

```swift
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/MultiPlatform/Source/Swift\ File.xctemplate/TemplateInfo.plist

```

> [@russellyi](#):
>
> ```swift
> <?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>SupportsSwiftPackage</key>
> <true/>
> <key>Kind</key>
> <string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
> <key>Description</key>
> <string>An empty Swift file for package.</string>
> <key>Summary</key>
> <string>An empty Swift file for package.</string>
> <key>SortOrder</key>
> <string>1</string>
> <key>Image</key>
> <dict>
> <key>FileTypeIcon</key>
> <string>swift</string>
> </dict>
> <key>AllowedTypes</key>
> <array>
> <string>public.swift-source</string>
> </array>
> <key>Platforms</key>
> <array />
> <key>DefaultCompletionName</key>
> <string>File</string>
> <key>MainTemplateFile</key>
> <string> ___FILEBASENAME___.swift</string>
> <key>Options</key>
> <array>
> <dict>
> <key>Identifier</key>
> <string>productName</string>
> <key>Required</key>
> <true/>
> <key>Name</key>
> <string>Name:</string>
> <key>Description</key>
> <string>The name of the file to create</string>
> <key>Type</key>
> <string>text</string>
> <key>NotPersisted</key>
> <true/>
> </dict>
> </array>
> </dict>
> </plist>
> 
> ```
