Templates for Swift files #35
Closed
wojciech-kulik
announced in
Tips & Tricks
Replies: 1 comment
-
|
Moved to Wiki |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Often, you want to have templates for specific files in your project or at least you want to have a header (like when using Xcode).
I created a small function that fills in a new file with predefined template. Based on the file name suffix it can use the relevant template.
This function is also able to replace some placeholders like
{date},{filename}, and{name}. If you place{cursor}in your template, the cursor will be automatically moved there.Sample template
templates/viewmodel.txt// // {filename}.swift // // // Created by YOUR_NAME on {date}. // Copyright © 2024 YOUR_COMPANY. All rights reserved. // import Foundation protocol {filename}Protocol: ObservableObject { var someProperty: String { get } } final class {filename}: {filename}Protocol { @Published var someProperty: String = "" init() { {@cursor@} } }Beta Was this translation helpful? Give feedback.
All reactions