Content deleted Content added
→Examples: The assertion that it's standard practice to separate app struct and view structs is common knowledge in the SwiftUI developer world but is difficult to cite. The assertion that the main view is called "ContentView" however is pure preference and personal style. I removed the assertion of preference as fact while leaving the assertion of broad convention in the hopes we can find a style guide to reference. |
and I got the wrong link, so much for double checking. See previous edit summary. |
||
(16 intermediate revisions by 12 users not shown) | |||
Line 10:
| genre = [[Software framework]]
| license = [[proprietary software|Proprietary]]
| website = https://developer.apple.com
}}
'''SwiftUI''' is a
== Overview ==
SwiftUI is [[Declarative programming|declarative]], contrasting with the [[Imperative programming|imperative syntax]] used in other Apple development frameworks such as [[UIKit]] and [[AppKit]]. SwiftUI allows for 2D drawing, animations, [[Event (computing)|event handling]], widgets, and [[data binding]]. SwiftUI automatically synchronizes between UI views and data.<ref>{{Cite web |title=SwiftUI |url=https://docs.developer.apple.com/documentation/swiftui |access-date=2024-01-10 |website=Apple Developer Documentation |language=en-US}}</ref>
SwiftUI integrates with other Apple
SwiftUI allows for interoperability with UIKit and AppKit views via the <code>UIViewRepresentable</code>
== History ==
Line 27:
During WWDC 2020 and the [[iOS 14]] release cycle, Apple natively added support for maps with the <code>Map</code> view, with an interface based on [[Apple Maps]] via MapKit.<ref>{{Cite web |title=MapKit for SwiftUI |url=https://docs.developer.apple.com/documentation/mapkit/mapkit_for_swiftui |access-date=2024-01-10 |website=Apple Developer Documentation |language=en-US}}</ref> MapKit allows for map annotation and satellite imagery.
During WWDC 2021 and the [[
During WWDC 2022 and the [[iOS 16]] release cycle, Apple released Swift Charts, a framework for making customizable and
During WWDC 2023, Apple announced the [[Apple Vision Pro]], and support for the device was added to SwiftUI, alongside new views for AR content such as <code>RealityView</code> and <code>ImmersiveSpace</code>.<ref>{{Cite web |title=Meet SwiftUI for spatial computing - WWDC23 - Videos |url=https://developer.apple.com/videos/play/wwdc2023/10109/ |access-date=2024-01-31 |website=Apple Developer |language=en}}</ref>
== Examples ==
The following is an example of a simple [["Hello, World!" program|Hello World]] program. The {{code|@main}} attribute defines the entry point into the app. It is standard practice in SwiftUI to separate the application struct and views into different structs, according to the [[Model–view–viewmodel|Model–View–ViewModel]] (MVVM) architectural pattern.<ref>{{
<syntaxhighlight lang="swift">
import SwiftUI
Line 46:
}
}
struct ContentView: View {
var body: some View {
Text("Hello, World!")
}
</syntaxhighlight>
|