SOLVED. Didn't have the script in an Editor folder. Why does Visual Studio Code flag this as a problem? It compiles fine in Unity. Have tried deleting sln and csproj files. Have also tried deleting Library folder. It's a new project with only this one source file. Platform is set to iOS.