7

So I'm new to Swift. I see it's a fast-moving language.

But so many tutorials I see have AppDelegate and SceneDelegate as standard init files, why don't I have any? Why can't I seem to find an option for them?

The tutorials include one from July 2020 so I'm guessing this is some sort of recent update. How should I approach the two types of apps with different file types? As a "Veteran" programmer, which is more advantageous?

Thanks everyone. Happy Coding.

Maxime Franchot
  • 1,015
  • 1
  • 10
  • 24
  • When a new project is created, XCode includes both AppDelegate and SceneDelegate files – cora Nov 16 '20 at 22:19

2 Answers2

5

The only way I know to get the result you did is to choose "SwiftUI" for Interface and "SwiftUI App" for Life Cycle in the New Project dialog. If you choose "Storyboard" for Interface, or "UIKit App Delegate" for Life Cycle, you will get the files you expected.

enter image description here

Casey Perkins
  • 1,853
  • 2
  • 23
  • 41
  • Amazing, thank you for your answer! I somehow missed those options.. they're on the second screen when you create a new project.. – Maxime Franchot Nov 16 '20 at 23:15
5

When creating a new iOS app, if you select SwiftUI App for the life cycle, this replaces the use of AppDelegate and SceneDelegate.

If you want a classic lifecycle delegate, you can select UIKit App Delegate instead.

Creating a Swift UI App

Alexander Li
  • 781
  • 4
  • 12
  • 1
    Amazing! What's the difference when using SwiftUI for the Lifecycle? – Maxime Franchot Nov 16 '20 at 23:14
  • 1
    SwiftUI is a lot simpler. It's like 17 lines of code that defines your entire app. Search up "SwiftUI Life Cycle" – aheze Nov 17 '20 at 01:05
  • Thanks for that tip to search it up, nice introduction to it here (from October 2020): https://peterfriese.dev/ultimate-guide-to-swiftui2-application-lifecycle/ . – user3773048 Dec 16 '21 at 16:27