UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Error when using onSubmit() - iOS 15

Forums > SwiftUI

The onSubmit view modifier is new to iOS 15. I was reading this HWS article (https://www.hackingwithswift.com/quick-start/swiftui/how-to-take-action-when-the-user-submits-a-textfield) about it, and tried to run the example snippet of code.

struct ContentView: View {
    @State private var password = ""

    var body: some View {
        SecureField("Password", text: $password)
            .onSubmit {
                print("Authenticating…")
            }
    }
}

However, I get an error saying "onSubmit(of:_:) is only available in iOS 15.0 or newer". I'm running the latest version of Xcode (Xcode 13), which was meant to support iOS 15 features? Any ideas what might be going on?

3      

Check the target of your app. Under the General tab in the Deployment Info section, is the target iOS 15.0?

Most likely it is set to iOS 14.7 or earlier.

You can also look under the Project Deployment Target on the Info tab for the same iOS setting.

3      

Your're quite right! Many thanks!

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.