Swift Playgrounds Autocomplete

I've started a Playgrounds in XCode 9.2 and for some reason autocomplete doesn't work properly, it suggests generic stuff unrelated to what I actually need, for example, if I want to do a super.init it suggests other words in the file that have 's' in them and 'switch', wich actually completes a switch stub. No matter what module I import, it never finds it's classes or methods. Can anyone help or is it a problem only Apple can solve in a future update?

Replies

Got the same problem 😟

Can confirm this issue. Code completion works in the main file, but not in any added .swift files. Not a fun issue to deal with when trying to create a WWDC scholarship playground.


If anyone finds a workaround, it would be appreciated.

I am seeing this as well. Real bummer, I love prototyping in playgrounds.

Ya.. Same problem while creating my WWDC18 submission.

But the same will not happen if you write it in main file (i.e. Playground Page file). It will only happen in resource file. So, what you can do is first write all the code in the main file and then cut-paste it in the resource file.

Or you can also try .playgroundbook

Did anyone identify a way to fix this issue? It's still happening for me. I'm also experiencing a lot of crashes.

I came across this https://stackoverflow.com/questions/46504286/xcode-9-autocomplete-not-working-100-partially-working

Try:

  1. Go to Xcode > Preferences > Text Editing
  2. Under Code completion - Uncheck 'Suggest completions while typing'
  3. Quit out of Xcode and then relaunch Xcode.
  4. Go to Xcode > Preferences > Text Editing again
  5. Quit out of Xcode and then relaunch Xcode.
  6. Now go to Code completion and check 'Suggest completions while typing'.
  7. Try typing library function or enum and enjoy!

and, strange as it looks, it worked for me.

I just cmd + q to quit Xcode and relaunch it. This seems to happen to me every time I add a playground page, so now I'm just in the habit of: Add new Playground Page > Quit Xcode > Relaunch Playground.

  • Agree with @wallstephen. Is the easy step to do, reboot your Xcode and your autocompleted will work!

Add a Comment

yep, this workaround works for the case if you added new playground page