Using Xcode File Templates for the Labs and Example Code
Did you know you can create your own custom file templates to use in Xcode? These have been a huge time saver in my work for Step Into Vision.
This article explores the process in more detail: Create Custom Xcode Templates.
My file template for the Labs:
~/Library/Developer/Xcode/Templates
// or
Library/Developer/Xcode/Templates/Step Into Lab.xctemplateCreate a file template with placeholder content that Xcode will populate
// Step Into Vision - Labs
//
// Title: ___FILEBASENAMEASIDENTIFIER___
//
// Subtitle:
//
// Description:
//
// Type:
//
// Created by ___FULLUSERNAME___ on ___DATE___.
import SwiftUI
import RealityKit
struct ___FILEBASENAMEASIDENTIFIER___: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
___FILEBASENAMEASIDENTIFIER___()
}Create a plist file with the metadata
<?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>A SwiftUI custom view for Step Into Labs</string>
<key>Summary</key>
<string>Step Into Lab</string>
<key>SortOrder</key>
<string>1</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>Platforms</key>
<array />
<key>DefaultCompletionName</key>
<string>Lab000</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___.swift</string>
<key>Image</key>
<dict>
<key>FileTypeIcon</key>
<string>swift</string>
</dict>
</dict>
</plist>Support our work so we can continue to bring you new examples and articles.

Follow Step Into Vision