Content deleted Content added
fixed logo size |
added version history |
||
Line 1:
{{Short description|Software development environment}}
{{
{{Infobox software
| logo = SwiftUI logo.png
Line 16:
== 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
SwiftUI integrates with other Apple services, such as [[Xcode]] and [[Swift Playgrounds]] to provide for real-time previews during editing,<ref name=":0">{{Cite web |title=Previews in Xcode |url=https://developer.apple.com/documentation/swiftui/previews-in-xcode |access-date=2023-11-07 |website=Previews in Xcode – Apple Developer Documentation |language=en |archive-url=https://web.archive.org/web/20231107221047/https://developer.apple.com/documentation/swiftui/previews-in-xcode |archive-date=2023-11-07}}</ref>
SwiftUI allows for interoperability with UIKit views via the <code>UIViewRepresentable</code> struct.<ref>{{Cite web |title=Interfacing with UIKit |url=https://docs.developer.apple.com/tutorials/swiftui/interfacing-with-uikit |access-date=2024-01-31 |website=Apple Developer Documentation |language=en-US}}</ref>
▲SwiftUI integrates with other Apple services, such as [[Xcode]] to provide for real-time previews during editing,<ref name=":0">{{Cite web |title=Previews in Xcode |url=https://developer.apple.com/documentation/swiftui/previews-in-xcode |access-date=2023-11-07 |website=Previews in Xcode – Apple Developer Documentation |language=en |archive-url=https://web.archive.org/web/20231107221047/https://developer.apple.com/documentation/swiftui/previews-in-xcode |archive-date=2023-11-07}}</ref> and support for maps with [[Apple Maps]].<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>
== History ==
SwiftUI was announced at the company's [[Worldwide Developers Conference]] (WWDC) on June 3, 2019, and was added in [[iOS 13]] and [[macOS Catalina]].<ref name="announcement"></ref>
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 [[IOS 16|iOS 15]] release cycle, Apple added the <code>Canvas</code> element, adding support for [[Immediate mode (computer graphics)|Immediate mode]] drawing and performant 2D drawing.<ref>{{Cite web |title=Canvas |url=https://docs.developer.apple.com/documentation/swiftui/canvas |access-date=2024-01-31 |website=Apple Developer Documentation |language=en-US}}</ref>
During WWDC 2022 and the [[iOS 16]] release cycle, Apple released Swift Charts, a framework for making customizable and acessible charts.<ref>{{Cite web |title=Swift Charts |url=https://docs.developer.apple.com/documentation/charts |access-date=2024-01-31 |website=Apple Developer Documentation |language=en-US}}</ref>
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. It is standard practice in SwiftUI to separate the application struct and views into different structs, with the main view named <code>ContentView</code>{{citation needed|date=January 2024}}.
<syntaxhighlight lang="swift">
import SwiftUI
|