Predefined SwiftUI code snippets in Xcode

I am a Software Engineer working on open source and enterprise mobile SDKs for iOS and MacOS developers written in Swift. From 🇩🇪 and happily living in 🇺🇸
Search for a command to run...

I am a Software Engineer working on open source and enterprise mobile SDKs for iOS and MacOS developers written in Swift. From 🇩🇪 and happily living in 🇺🇸
No comments yet. Be the first to comment.
WWDC26 kicked off on June 8, 2026. The information in this article reflects the information published by Apple on that date. There are 14 new frameworks. Name Description AccessoryAccess Manage

WWDC25 kicked off on June 9, 2025. The information in this article reflects the information published by Apple on that date. New Frameworks NameDescription AlarmKitSchedule prominent alarms and countdowns to help people manage their time. AVR...

WWDC25 is almost here, and I couldn’t be more excited! Whether you're attending the official events, community meetups, or just soaking in the energy around Cupertino, there’s no better time to connect, share ideas, and celebrate everything we love a...

In this blog post, I’ll share an observation and advice regarding the caching behavior of network responses by Apple’s APIs. If you are unfamiliar with caching of network responses then I recommend Apple’s article Accessing cached data that introduce...
WWDC24 kicked off on June 10, 2024. The information in this article reflects the information published by Apple on that date. New Frameworks NameDescription AccessorySetupKitUse AccessorySetupKit to discover accessories with Bluetooth or Wi-Fi...

Xcode includes predefined, top-level, SwiftUI code snippets which are not visible in the library (⇧⌘L).

Snippets are indicated with {} (curly brackets) in the autocompletion list.

I was able to find the following snippets:
The snippets define placeholder tokens that can easily be substituted with the desired value during autocompletion.

What follows is the default output for each snippet.
struct MyButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.padding()
.background(.quaternary, in: Capsule())
.opacity(configuration.isPressed ? 0.5 : 1)
}
}
struct MyButtonStyle_Previews: PreviewProvider {
static var previews: some View {
Button(action: { print("Pressed") }) {
Label("Press Me", systemImage: "star")
}
.buttonStyle(MyButtonStyle())
}
}
struct MyLabelStyle: LabelStyle {
func makeBody(configuration: Configuration) -> some View {
HStack {
configuration.icon
.frame(width: 50)
.background(.quaternary, in: Circle())
configuration.title
Spacer()
}
}
}
struct MyLabelStyle_Previews: PreviewProvider {
static var previews: some View {
VStack {
Label("Title 1", systemImage: "star")
Label("Title 2", systemImage: "square")
Label("Title 3", systemImage: "circle")
}
.labelStyle(MyLabelStyle())
}
}
struct MyPreviewProvider_Previews: PreviewProvider {
static var previews: some View {
Text("Hello, world!")
}
}
struct MyShape: Shape {
func path(in rect: CGRect) -> Path {
Path { path in
path.addEllipse(in: rect)
}
}
}
struct MyShape_Previews: PreviewProvider {
static var previews: some View {
MyShape()
}
}
struct: View {
var body: some View {
Hello, world!
}
}
struct MyView_Previews: PreviewProvider {
static var previews: some View {
MyView()
}
}
struct MyModifier: ViewModifier {
func body(content: Content) -> some View {
content
.padding()
.background(.quaternary, in: Capsule())
}
}
struct MyModifier_Previews: PreviewProvider {
static var previews: some View {
Text("Hello, world!")
.modifier(MyModifier())
}
}