0

I am Trying to create a new Swift File (UIViewController) to link it to a a viewController in the Interface Builder. I have chosen cocoa touch class / Swift as a language. However, when the created, it's appearing red texted, with a greyed out icon, when click it nothing happened or displays "no editor". I expect to see the code / imports.

Am I missing something?

Thanks.

jscs
  • 63,694
  • 13
  • 151
  • 195
uwotm8
  • 123
  • 3
  • 10

2 Answers2

4

File -> New -> File -> Swift File

Rob
  • 2,649
  • 3
  • 27
  • 34
1

There are at least three ways to add Swift file to your existing project:

  1. File – New – File... – Swift File
  2. RMB in Project Navigator – New File – Swift File
  3. Cmd + NSwift File

All three must work as expected. If not, restart Xcode and create a project from scratch.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • I have been doing 2. I have just restarted Xcode, and attempted 1 and 3. The file is created, but the text is red, their is no code view, and when clicked on displays "no editor" – uwotm8 Oct 16 '16 at 16:25
  • @uwotm8 Try this: http://stackoverflow.com/questions/5409015/app-file-appears-in-red-missing-in-new-projects-with-xcode-4 – Andy Jazz Oct 16 '16 at 16:31
  • Although, there are some discrepancies between Xcode 4 and Xcode 8. – Andy Jazz Oct 16 '16 at 16:34