0

I'm trying to make a SwiftUI created on Xcode 13 work on Xcode 11 (or iOS 13).

There's a similar post here but the suggestions doesn't seem to work on Xcode 11.

My current entrypoint looks like:

@main  // <- this does not work on Xcode 11!
struct MyAppWrapper {
    static func main() {
        if #available(iOS 14.0, *) {
            MyApp.main()
        } else {
            UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(AppDelegate.self))
        }
    }
}

@available(iOS 14.0, *)
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

As in the comment above, Xcode 11 doesn't support @main. I would like to use AppDelegate for iOS 13, but use Scene and WindowsGroup method on iOS 14 and above.

I can't believe making a SwiftUI project that works across iOS 13~15 is this difficult..

What else can I try?


Update

Info.plist:

enter image description here

MyApp.swift:

enter image description here

AppDelegate.swift:

enter image description here

SceneDelegate.swift:

enter image description here

17
  • There's no need to use Xcode 11 - just set your app's deployment target to iOS 13 and you're done. Commented Mar 22, 2022 at 10:48
  • @Gereon Thanks for the comment. I'm using Xcode 11 so that I can build and test my project on iOS 13 SDK. Are you suggesting that even with the newer versions of Xcode, I can still build and test using iOS 13 SDK? (FYI, I'm using Github Actions for CI/CD) Commented Mar 22, 2022 at 10:52
  • No, with Xcode 13 you're building with the iOS 15 SDK, but since need to support iOS 14 and 15, that's precisely what you need and want to do. Setting the deployment target is really all you need to do, the compiler will keep you from using newer features without appropriate if #available checks. Commented Mar 22, 2022 at 11:32
  • @Gereon Not only iOS 14 and 15, I also need to support iOS 13, which is whole point of this question. Commented Mar 22, 2022 at 11:51
  • Does this answer your question? How to generate iOS 13 SwiftUI project in XCode? Commented Mar 22, 2022 at 11:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.