Content deleted Content added
rewrote basically everything to make the article sound less like an advertisement. |
and I got the wrong link, so much for double checking. See previous edit summary. |
||
(36 intermediate revisions by 18 users not shown) | |||
Line 1:
{{Short description|
{{One source|date=January 2024}}
}}▼
{{Infobox software
| logo = SwiftUI logo.png
| logo size = 85px
| name = SwiftUI
| developer = [[Apple Inc.]]
Line 13 ⟶ 10:
| genre = [[Software framework]]
| license = [[proprietary software|Proprietary]]
| website =
}}
'''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
SwiftUI integrates with other Apple
SwiftUI allows for interoperability with UIKit and AppKit views via the <code>UIViewRepresentable</code> and <code>NSViewRepresentable</code> protocols respectively.<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><ref>{{Cite web |title=AppKit integration |url=https://developer.apple.com/documentation/swiftui/appkit-integration |access-date=2024-10-06 |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 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 accessible 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|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>{{Cite book |last=Hudson |first=Paul |title=Swift Design Patterns |publisher=Paul Hudson |year=2018 |language=English}}</ref>{{self-published source inline|date=April 2024}}
<syntaxhighlight lang="swift">
import SwiftUI
@main
struct AnApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
struct ContentView: View {
var body: some View {
Text("Hello, World!")
}
}
</syntaxhighlight>
== References ==
Line 27 ⟶ 59:
== External links ==
* [https://developer.apple.com/documentation/swiftui/ SwiftUI] at [[Apple Developer]]
==Further reading==
Line 35 ⟶ 66:
{{iOS}}
[[Category:Gesture recognition]]
[[Category:IOS]]
|