Second clue
Etienne Vautherin - 2024/06/03
This article is part of the detective fiction about iOS 18
The SwiftUI App Scene
doesn’t have any backstage!
The SwiftUI app is efficient, its scene is elegant, but the actors appear on stage without any advice or makeup. This could lead to creative and funny performances. However, this doesn’t seem like a very professional approach!
On the alternative mobile software development, Google carefully describes (using imperative Kotlin) a data-layer for Android apps while, without any directive from Apple, the data flow of an iOS app today is a full improvisation.
So, what does it mean to add a backstage to the SwiftUI App Scene
?
From the very first day, SwiftUI defines the State
structure to achieve the famous declarative UI equation:
\[ UI = f(State) \]
This function \(f\) is declared in Swift by composing SwiftUI elements that appear in a WindowGroup
of a Scene
.
However, today, there is no Swift declaration between the @main
annotation (which represents the entry point of our app) and the appearance of values for State
.
@main
struct SomeApp: App {
// 🤔 Where is the backstage defined???
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
In a very broad sense, the UI depends on the physical environment of the mobile device (in a very broad sense to include notions as varied as memory zone, network request, etc.). This physical environment can be represented by a value called Sensor
and by a function \(h\) that allows us to obtain the UI for a given value of the physical environment:
\[ UI = h(Sensor) \]
If we define a function \(g\) such that \( State = g(Sensor) \), we then have:
\[ UI = f(State) \implies UI = f(g(Sensor)) \]
\[ UI = f(g(Sensor)) \implies h = f \circ g \]
The same way \(f\) is declared in Swift by composing SwiftUI elements, Apple could define some new composable elements to declare \(g\).
In other words, the presence of \(g\), a superior declarative intelligence behind the SwiftUI app Scene
, is very likely. We will therefore make Activity
our prime suspect or, at the very least, a key accomplice for a role of composable element to declare the \(g\) function!