TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn 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.