aMike
aMike

Reputation: 937

Xcode generates project template that doesn't compile

I'm on Mojave 10.14.6, and installed Xcode 11.3.1. Swift says it's version 5.1.3. I thought this was OK according to the Xcode release notes: "Xcode 11.3.1 requires a Mac running macOS Mojave 10.14.4 or later." And the notes for Swift said Swift 5.1 needs macOS 10.14.6 and Xcode 11 or later.

In Xcode, when I create a new 'nothing' macos app, Xcode generates this in one of the files:

struct ContentView: View {
    var body: some View {
        Text("Hello, World!")
            .frame(maxWidth: .infinity, maxHeight: .infinity)
    }
}

When I build this, I get these errors:

In the project General settings, I set Deployment to 10.14, but that comes too late - the empty app was already generated for 10.15.

In the Build Settings, Deployment is set to 10.14 and the Swift compiler is set to Swift 5.

Is there a way to tell Xcode 11.3.1 to setup a project that will build and run on 10.14.6?

Or do I need to drop back to Xcode 10.3? (the next oldest release?).

Thanks!

EDIT: is it because I used the default SwiftUI? I just tried Storyboard and the generated code built ok. So... it's a problem with xcode generating SwiftUI code that Mojave can't build?

Upvotes: 1

Views: 207

Answers (1)

aMike
aMike

Reputation: 937

I figured it out. Although XC 11.3.1 can run on 10.14.6, the SDK is 10.15. I went back to XC 10.3, which was the last version with the 10.14 SDK.

This gives Apple Swift version 5.0.1 and Apple LLVM version 10.0.1 (clang-1001.0.46.4)

Now I wonder if I can use SwiftUI with Swift 5.0.1 in XC 10.3 on 10.14.6 Mojave? "Outlook not so good." says Magic 8 Ball. :-)

Thank you xcodereleases.com; I should have looked more carefully before. Sorry for the noise.

Upvotes: 1

Related Questions