UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Frustrating autocomplete Xcode 15

Forums > SwiftUI

Before Xcode 15, when I started typing Button and selected Button(action:label:) from the menu and pressed enter twice, it changed to

Button {

} label: {

}

However, in Xcode 15, it now changes to:

Button(action: {}, label: {
    Text("Button")
})

Is there an option to revert to the 'old' completion behavior?

2      

Try xcode settings up at the top left, key bindings. Might work.

2      

The best thing I've found so far is to write:

Butr

and then go down one to Button(role:action:label:) and hit Return.

Then you'll find the ButtonRole? field highlighted. Just Delete (backspace) on that to remove it and Tab to highlight the Action? field and hit Enter. Then you'll have the setup you're looking for. It's pretty quick once muscle memory sets in.

When you hit Delete on ButtonRole? you'll end up with Button(role: , action: () -> Void , label: () -> View) but you don't have to clean up the 'role: ,' part. Just Tab to action and Enter.

2      

Type in Xcode the Button you want to use

Button {

} label: {

}

Highlight the code

Go to Editor > Create code snippet

Change name to something meaniful EG My Button

Add placeholder in action by doing <#action#> and <#label#>

In Completion add btn

Button{
    <#action#>
} label: {
    <#label#>
}

so anytime you want a Button type btn and select "My Button"

4      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.