Code greyed out

What causes code to be greyed out without the ability to type and have the autocomplete not show up, like in the picture provided var should be showing up on line 31 but its not

I must admit I have never seen that before.

What happens if you add a new swift file to your project?

From the menu select File > New > File…
Select “Cocoa Touch Class”
click “Next”
In the ‘Class’ field, name it “NewViewController” (just as an example) with a subclass of “UIViewController”
click “Next”
then Click “Create”

Does the file contents look normal for that new one?

The other question is, did you change your Xcode Theme in Preferences?

If all else fails, restart Xcode.

I usually see this behavior when:

  1. adding a new file and then moving it into a group folder (rather than creating it in that folder to begin with), or
  2. there is an error somewhere in my code and Xcode gets confused

Closing and reopening the project usually fixes it, although particularly stubborn cases require cleaning the build folder and/or restarting Xcode.

I tried adding a new swift and cocoa touch file, tried copy and pasting into the new files, Xcode preferences were still normal as I had another project open and all the colours and behaviours were right in that one. I restarted Xcode.

I think @roosterboy got it right, I have since completely made a new project and redid everything I had done up until that point but I changed where the Core Data files were being saved to and it didn’t exhibit the same unwanted behaviour. I think it was when I moved those files into my Model folder that the issue happened. I had tried cleaning and rebuilding but it didn’t work before I resaved where the files were being saved to.