WWDC23 SALE: Save 50% on all my Swift books and bundles! >>

SOLVED: Wrong version of Xcode/Swift or am I missing something?

Forums > SwiftUI

Hi guys,

New to SwiftUI/coding in general, and was wondering if someone could help me.

Going through the 100 Days of SwiftUI, everything was fine with the Playground work, but I've encountered some problems with Project 1 and 2 with some of the code not building on my SwiftUI. For example the code below for Project 1 doesn't seem to work, and the error below it is given.

TextField("Amount", value: $checkAmount, format: .currency(code: Locale.current.currencyCode ?? "USD"))

Cannot infer contextual base in reference to member 'currency'. Extra argument 'format' in call Missing argument for parameter 'formatter' in call Insert ', formatter: <#Formatter#>'

I managed to get around this (kind of) with 'NumberFormatter()', but I am now struggling with Project 2 as I can't do simple button styling such as:

VStack {
    Button("Button 1") { }
        .buttonStyle(.bordered)
    Button("Button 2", role: .destructive) { }
        .buttonStyle(.bordered)
    Button("Button 3") { }
        .buttonStyle(.borderedProminent)
    Button("Button 4", role: .destructive) { }
        .buttonStyle(.borderedProminent)
}

I am using a MacBook Pro 2012 and running Catalina 10.15.7 which means I can only run Xcode 12.1, but looking online I can't seem to find any reference to styling such as '.bordered' not being available on this version and so wondering if I'm missing something obvious.

Looking to upgrade my MacBook at the end of the month but would like to continue as much as possible up until then.

Any help would be appreciated, thank you.

   

Nathan jumps directly into the deep end:

I am running Catalina 10.15.7 meaning I can only run Xcode 12.1, but looking online I can't seem to find any reference to styling such as '.bordered' not being available

I found this reference in Apple's documentation. If you look at the rightmost panel, you'll see Availability is iOS 15.0+

In your Swift project, you can set the target OS version for the application you're developing. Check that to see if iOS 15.0 or higher is an option.

See-> Apple: Bordered Button Style

I wrote a similar response last year for a similar problem. Maybe this helps?

See-> Let's Play a Game

   

Nathan jumps directly into the deep end:

Sorry, this went well above my head.

I found this reference in Apple's documentation. If you look at the rightmost panel, you'll see Availability is iOS 15.0+

Ah yes, thank you for that, I see now! Yes unfortunately iOS 15 is not available, 14.1 is my latest version - guess I need to upgrade then!

Thanks for your response, appreciate it.

   

Nathan jumps directly into the deep end:

It the vast swimming pool of problems that plague developers, you "jumped into the deep end" and found a difficult one!

Some problems might be easy to fix, replacing "var" with "let", using == rather than =. These might be "shallow end" problems.

Come for the Swift discussion, get a free colloquialism lesson.

   

Save 50% in my WWDC23 sale.

SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.