SwiftUI

Last updated
SwiftUI
Developer(s) Apple Inc.
Initial releaseJune 3, 2019
Operating system iOS, iPadOS, macOS, tvOS, watchOS, visionOS
Type Software framework
License Proprietary
Website https://developer.apple.com/xcode/swiftui/

SwiftUI is a user interface framework [1] for building user interfaces for iOS, iPadOS, watchOS, tvOS, visionOS and macOS, developed by Apple Inc. for the Swift programming language.

Contents

Overview

SwiftUI is declarative, contrasting with the imperative syntax used in other Apple development frameworks such as UIKit and AppKit. SwiftUI allows for 2D drawing, animations, event handling, widgets, and data binding. SwiftUI automatically synchronizes between UI views and data. [2]

SwiftUI integrates with other Apple services, such as Xcode and Swift Playgrounds to provide for real-time previews during editing, [3] [4] alongside support for debugging and other development features.

SwiftUI allows for interoperability with UIKit views via the UIViewRepresentable struct. [5]

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. [1]

During WWDC 2020 and the iOS 14 release cycle, Apple natively added support for maps with the Map view, with an interface based on Apple Maps via MapKit. [6] MapKit allows for map annotation and satellite imagery.

During WWDC 2021 and the iOS 15 release cycle, Apple added the Canvas element, adding support for Immediate mode drawing and performant 2D drawing. [7]

During WWDC 2022 and the iOS 16 release cycle, Apple released Swift Charts, a framework for making customizable and acessible charts. [8]

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 RealityView and ImmersiveSpace. [9]

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[ citation needed ].

importSwiftUI@mainstructAnApp:App{varbody:someScene{WindowGroup{ContentView()}}}structContentView:View{varbody:someView{Text("Hello, World!")}}

Related Research Articles

Cocoa is Apple's native object-oriented application programming interface (API) for its desktop operating system macOS.

<span class="mw-page-title-main">WebObjects</span> Java web application server and framework originally developed by NeXT Software

WebObjects is a discontinued Java web application server and a server-based web application framework originally developed by NeXT Software, Inc.

<span class="mw-page-title-main">Xcode</span> IDE including tools for developing software for Apple platforms

Xcode is Apple's integrated development environment (IDE) for macOS, used to develop software for macOS, iOS, iPadOS, watchOS, tvOS, and visionOS. It was initially released in late 2003; the latest stable release is version 15, released on September 18, 2023, and is available free of charge via the Mac App Store and the Apple Developer website. Registered developers can also download preview releases and prior versions of the suite through the Apple Developer website. Xcode includes command-line tools that enable UNIX-style development via the Terminal app in macOS. They can also be downloaded and installed without the GUI.

The Worldwide Developers Conference (WWDC) is an information technology conference held annually by Apple Inc. The conference is usually held at Apple Park in California. The event is usually used to showcase new software and technologies in the macOS, iOS, iPadOS, watchOS, and tvOS families as well as other Apple software; new hardware products are sometimes announced as well. WWDC is also an event hosted for third-party software developers that work on apps for iPhones, iPads, Macs, and other Apple devices. Attendees can participate in hands-on labs with Apple engineers and attend in-depth sessions covering a wide variety of topics.

<span class="mw-page-title-main">AppKit</span> Graphical user interface toolkit

AppKit is a graphical user interface toolkit. It initially served as the UI framework for NeXTSTEP. Along with Foundation and Display PostScript, it became one of the core parts of the OpenStep specification of APIs. Later, AppKit and Foundation became part of Cocoa, the Objective-C API framework of macOS. GNUstep, GNU's implementation of the OpenStep/Cocoa API, also contains an implementation of the AppKit API.

The Apple Developer Tools are a suite of software tools from Apple to aid in making software dynamic titles for the macOS and iOS platforms. The developer tools were formerly included on macOS install media, but are now exclusively distributed over the Internet. As of macOS 10.12, Xcode is available as a free download from the Mac App Store.

<span class="mw-page-title-main">Dashcode</span>

Dashcode was a software application created by Apple Inc. that was included with Mac OS X Leopard and facilitates the development of widgets for Dashboard. It was first included on new MacBooks shipping around the time of May 24, 2006, as part of the Xcode developer tools.

Swift is a high-level general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community. Swift compiles to machine code, as it is an LLVM-based compiler. Swift was first released in June 2014, and the Swift toolchain has shipped in Xcode since version 6, released in 2014.

AVFoundation is a multimedia framework with APIs in Objective-C and Swift, which provides high-level services for working with time-based audiovisual media on Apple Darwin-based operating systems: iOS, macOS, tvOS, and watchOS. It was first introduced in iOS 4 and has seen significant changes in iOS 5 and iOS 6. Starting with Mac OS X Lion, it is now the default media framework for the macOS platform.

tvOS Operating system for the Apple TV

tvOS is an operating system developed by Apple Inc. for the Apple TV, a digital media player. In the first-generation Apple TV, Apple TV Software was based on Mac OS X. Starting with the second generation, the software is based on the iOS operating system and has many similar frameworks, technologies, and concepts.

WatchKit is a framework provided by Apple to develop applications for the Apple Watch. The WatchKit framework is designed for the Swift programming language and also the Objective-C programming language and must be compiled in Xcode, similar to iOS applications.

SceneKit, sometimes rendered Scene Kit, is a 3D graphics application programming interface (API) for Apple Inc. platforms written in Objective-C. It is a high-level framework designed to provide an easy-to-use layer over the lower level APIs like OpenGL and Metal. SceneKit maintains an object based scene graph, along with a physics engine, particle system, and links to Core Animation and other frameworks to easily animate that display. SceneKit views can be mixed with other views, for instance, allowing a SpriteKit 2D display to be mapped onto the surface of an object in SceneKit, or a UIBezierPath from Core Graphics to define the geometry of a SceneKit object. SceneKit also supports import and export of 3D scenes using the COLLADA format. SceneKit was first released for macOS in 2012, and iOS in 2014.

Flutter is an open-source UI software development kit created by Google. It can be used to develop cross platform applications from a single codebase for the web, Fuchsia, Android, iOS, Linux, macOS, and Windows. First described in 2015, Flutter was released in May 2017. Flutter is used internally by Google in apps such as Google Pay and Google Earth as well as by other software developers including ByteDance and Alibaba.

ARKit is an application programming interface (API) for iOS, iPadOS and VisionOS which lets third-party developers build augmented reality apps, taking advantage of a device's camera, CPU, GPU, and motion sensors. The ARKit functionality is only available to users of devices with Apple A9 and later processors. According to Apple, this is because "these processors deliver breakthrough performance that enables fast scene understanding and lets you build detailed and compelling virtual content on top of real-world scenes." The SDK was first released for IOS 11 in 2017, and was preinstalled in the initial release of IPadOS 13 in 2019 and visionOS 1.0 in 2024. In visionOS, however, ARKit plays a lesser role in augmented reality than in iOS and iPadOS. ARKit in visionOS is focused on acquiring data about the person’s surroundings, while SwiftUI and RealityKit control the placement of any 2D or 3D content in the person’s surroundings, and SwiftUI or UIKit are used to build windows with an app's content.

<span class="mw-page-title-main">Swift Playgrounds</span> Development environment for Swift

Swift Playgrounds is an educational tool and development environment for the Swift programming language developed by Apple Inc., initially announced at the WWDC 2016 conference. It was introduced as an iPad application alongside iOS 10, with a macOS version introduced in February 2020. It is available for free via Apple's App Store for iPadOS and Mac App Store for macOS.

<span class="mw-page-title-main">IPadOS 14</span> 2020 tablet operating system by Apple Inc.

iPadOS 14 is the second major release of the iPadOS operating system developed by Apple for their iPad line of tablet computers. It was announced on June 22, 2020 at the company's Worldwide Developers Conference (WWDC) as the successor to iPadOS 13, making it the second version of the iPadOS fork from iOS. It was released to the public on September 16, 2020. It was succeeded by iPadOS 15 on September 20, 2021.

macOS Big Sur 17th major version of the macOS operating system

macOS Big Sur is the seventeenth major release of macOS, Apple Inc.'s operating system for Macintosh computers. It was announced at Apple's Worldwide Developers Conference (WWDC) on June 22, 2020, and was released to the public on November 12, 2020.

iOS 15 2021 mobile operating system

iOS 15 is the fifteenth major release of the iOS mobile operating system developed by Apple for its iPhone and iPod Touch lines of products. It was announced at the company's Worldwide Developers Conference on June 7, 2021, as the successor to iOS 14 and released to the public on September 20, 2021.

visionOS Mixed Reality operating system made by Apple

visionOS is a mixed reality operating system derived primarily from iOS core frameworks, and MR-specific frameworks for foveated rendering and real-time interaction. It was developed by Apple Inc. exclusively for its Apple Vision Pro mixed reality headset. It was unveiled on June 5, 2023, at Apple's WWDC23 event alongside the reveal of the Apple Vision Pro. The software released on February 2, 2024, shipping with the Apple Vision Pro.

ArkUI is a declarative based user interface framework for building user interfaces on native HarmonyOS applications developed by Huawei for the ArkTS and Cangjie programming language.

References

  1. 1 2 Mayo, Benjamin (June 3, 2019). "Apple announces SwiftUI, a modern declarative user interface framework for Apple platforms". 9to5mac.com. Retrieved January 22, 2024.
  2. "SwiftUI". Apple Developer Documentation. Retrieved 2024-01-10.
  3. "Previews in Xcode". Previews in Xcode – Apple Developer Documentation. Archived from the original on 2023-11-07. Retrieved 2023-11-07.
  4. "Swift Playgrounds". Apple Developer. Retrieved 2024-01-31.
  5. "Interfacing with UIKit". Apple Developer Documentation. Retrieved 2024-01-31.
  6. "MapKit for SwiftUI". Apple Developer Documentation. Retrieved 2024-01-10.
  7. "Canvas". Apple Developer Documentation. Retrieved 2024-01-31.
  8. "Swift Charts". Apple Developer Documentation. Retrieved 2024-01-31.
  9. "Meet SwiftUI for spatial computing - WWDC23 - Videos". Apple Developer. Retrieved 2024-01-31.

Further reading