1

I want to know my project use swiftUI 3 or swiftUI 4 .

env xcode 13.2.1

i hav try to google for answer , and read the apple documentation, and look setting of project and settings of Xcode's preference.

Lonyui
  • 93
  • 9

1 Answers1

2

The SwiftUI version relates to the iOS version. You could verify the version using the available API

if #available(iOS 13, *) {
    // SwiftUI 1.0
} else if #available(iOS 14, *) {
    // SwiftUI 2.0
} else if #available(iOS 15, *) {
    // SwiftUI 3.0
} else if #available(iOS 16, *) {
    // SwiftUI 4.0
}

Here you can find some solutions here

Carsten
  • 581
  • 4
  • 17
  • does this work exactly like this for macOS as well? – Cyril Mar 11 '23 at 15:32
  • @Cyril SwiftUI 1.0 was released with Catalina so you could test for `if #available(macOS 10.15, *)` or `if #available(macCatalyst 10.15, *)` and increase the versions accordingly, but I didn't test it – Carsten Apr 11 '23 at 06:01
  • @Carsten Nice answer--this info is surprisingly hard to find online. You would think if you google "SwiftUI 3.0", the top link would be Apple's documentation giving a "what's new" list, but nothing like that. Did you find this info somewhere? Or you knew it based on recollection of the iOS releases? – James Toomey Apr 21 '23 at 13:53
  • @JamesToomey I just searched for "what's new in iOS x" and checked the documentation – Carsten Apr 22 '23 at 17:15