Suggestion Completion Not Functioning Completely in Xcode 14.1

I am having issues with the suggestion completion feature in the playground of Xcode. It appears that some of the control flow statements do not populate as expected. For example, when I type out switch, it suggests the switch statement, but does not fully populate the parenthesis, curly brackets, and the text placeholders that allow you to input the expressions or variables you want to use. Instead you just get the statement. I also noticed that the icon that should appear before the statement does not have the usual "{}" icon, but instead there's a dot. I have seen this work before because I am currently taking online courses for swift, which uses playground to demonstrate how the code functions. I have already went ahead and turned this feature off then back on again, closing the application in between the steps. I have attached screenshots that would hopefully demonstrate what I'm experiencing. Any help is greatly appreciated.

Answered by Claude31 in 736031022

I tested on Xcode 14.1. Same settings as yours. It works correctly (need to type in lowercase, not uppercase):

The suggestions:

After selecting the second template:

Also tested in playground (you should have explicited this point).

There it works OK, but ONLY if you type inside a func. Not if you type at the top level of playground code.

In fact, autocompletion in playground seem to follow the rules of autocompletion in app code, where having switch at top level of a class (outside a func) would not make sense.

If this is not the appropriate forum to report this specific issue, please let me know which is a more proper site to post this for help. Thanks in advance!

Accepted Answer

I tested on Xcode 14.1. Same settings as yours. It works correctly (need to type in lowercase, not uppercase):

The suggestions:

After selecting the second template:

Also tested in playground (you should have explicited this point).

There it works OK, but ONLY if you type inside a func. Not if you type at the top level of playground code.

In fact, autocompletion in playground seem to follow the rules of autocompletion in app code, where having switch at top level of a class (outside a func) would not make sense.

I have tried the control flow statements within a function and the templates do indeed populate as expected. Perhaps the tutorial I was following demonstrated their code with an earlier version of Xcode, which probably allowed these templates to populate from the top level, outside of functions in playground. Thanks for the reply!

Suggestion Completion Not Functioning Completely in Xcode 14.1
 
 
Q