Xcode switching languages

Hi Everyone,

Why is it that Xcode switches from Swift to Objective-C after a certain number of scenes? This is how I am set up: Navigation contoller with main scene. Main scene has a button that leads the user to another scene made up of a UIwebview, Navigation button and a Navigation button. When I open Assistant Editor in order to add webviewcode, an objective-c file opens up. Is there something that I may have missed? From what I read, setting the language to Swift at the beginning of a project is all that's needed to work in Swift only.


Thanks!

Here's the current setup:


Navigation Controller-->Main Scene-->6 Other Scenes segue from Main Scene


Only 1 of the Other Scenes allows coding in Swift via the Assistant Editor. The 5 remaining Other Scenes show Objective-C code.

Xcode is taking the class class responsible for that scene (which you set in the Identity inspector after selecting the scene’s view controller), finding the implementation of that class, and showing you that. If that class is implemented in Objective-C, that’s what you get.

Xcode can’t automatically translate Objective-C to Swift, so if you want this class to be in Swift you will have to do something like this:

  1. create a replacement class with a slightly different name

  2. write a Swift version of the existing Objective-C code

  3. use the Identity inspector to change the class of the scene’s view controller to your new class

  4. optionally, once everything is done, delete the old Objective-C class and rename the Swift class back to the original name

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks, Quinn. I'll give it a shot.

Xcode switching languages
 
 
Q