I want to create a custom Xcode playground template for SwiftUI View. What file formats are used? How can I find examples? Where should I put those files?
Asked
Active
Viewed 306 times
1 Answers
0
You can make template by duplicating file templates at path
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Playground
Note that each platform has it's own templates.
- Copy two folders
TEMPLATE_NAME.xctemplate
andTEMPLATE_NAME___FileMenu.xctemplate
to~/Library/Developer/Xcode/Templates/File Templates
and rename them as you want.
(you can put it in subfolder SwiftUI
, it's name will be used to separate your templates from others)
- To change the displayed name of template you can change
Name
field inTemplateInfo.plist
- Paste the code of your template into
___FILEBASENAME___.playground
file (you can use placeholders to generate code base on parameters, see for example this article)
Here are my templates as an example: https://github.com/DanSkeel/XcodeTemplates/tree/main/Playground
Note:
...___FileMenu.xctemplate
files will be used when you create new file from opened playground.

DanSkeel
- 3,853
- 35
- 54