error CS0234: The type or namespace name `iOS' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?

If you're facing with this problem there are 2 steps to solve it:

  1. Make sure that "iOS Build Support" is checked in Unity Hub -> Installs as Adam mentioned (if U're developing for iOS platform then this option most definitely is already checked).
  2. Place your script in Assets -> Editor folder. UnityEditor.iOS.Xcode namespace cannot be used in your main project. It works only in special Assembly-CSharp-Editor project intended to modify native Xcode project. (That's the option that worked for me after searching a ton of forums).

The Official Solution: https://forum.unity.com/threads/unityeditor-ios-xcode-ios-namespace-doesnt-exist.365381/

Step by step I did: Figure 1 shows the Unity Download Assistent installation file that should be run.

Figure 1 - Unity Download Assistant

Figure 2 shows the "iOS Build Support" option that should be checked for installation.

Figure 2 - Unity Install iOS Build Support