Type 'ToggleStyle' has no member 'switch'

My big project started throwing errors: Type 'ToggleStyle' has no member 'switch'

Made new test project:




struct ContentView: View {

	@State var isOn = false

    var body: some View {

        Text("Hello, world!")

            .padding()

			Toggle(isOn: $isOn) {

							Text("IPv6")

					}

			.toggleStyle(.switch)


    }

}



struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}

Throws the same error: Type 'ToggleStyle' has no member 'switch'

what's wrong with this code ?

Answered by OOPer in 690897022

after i upgraded Xcdoe 13 beta to Xcode 13 i lost ability to build for 12.0

Please check the Software Download page of Xcode 13

Applications

Xcode 13

Xcode 13 includes everything you need to create and submit apps to the App Store for all Apple platforms. It Includes the SDKs for iOS 15, iPadOS 15, watchOS 8, tvOS 15, and macOS Big Sur. To continue developing apps for macOS Monterey, use Xcode 13 beta 5.

i can't event download Xcode-beta 13

You can download Xcode 13 beta 5 from the link on the page above, or you can download older Xcodes from the More Download pages.


Or you can use SwitchToggleStyle() explicitly:

            Toggle(isOn: $isOn) {
                            Text("IPv6")
                    }
            .toggleStyle(SwitchToggleStyle())

I tested your exact code, it works (Xcode 13).

Which version of Xcode do you use ? It is not available before iOS 13.

You may try enclosing switch in backquotes.

I believe this is related to this warning of Xcode 13.0 oficial release(13A233)(not beta). macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 12.0, but the range of supported deployment target versions is 10.9 to 11.3.99.

So it seems after i upgraded Xcdoe 13 beta to Xcode 13 i lost ability to build for 12.0... And now i can't event download Xcode-beta 13... Ideas ?

Accepted Answer

after i upgraded Xcdoe 13 beta to Xcode 13 i lost ability to build for 12.0

Please check the Software Download page of Xcode 13

Applications

Xcode 13

Xcode 13 includes everything you need to create and submit apps to the App Store for all Apple platforms. It Includes the SDKs for iOS 15, iPadOS 15, watchOS 8, tvOS 15, and macOS Big Sur. To continue developing apps for macOS Monterey, use Xcode 13 beta 5.

i can't event download Xcode-beta 13

You can download Xcode 13 beta 5 from the link on the page above, or you can download older Xcodes from the More Download pages.


Or you can use SwitchToggleStyle() explicitly:

            Toggle(isOn: $isOn) {
                            Text("IPv6")
                    }
            .toggleStyle(SwitchToggleStyle())
Type 'ToggleStyle' has no member 'switch'
 
 
Q