Find the SwiftUI Views that Update the Most Using Instruments Β· Swift Dev Journal
The following article shows how to use the new SwiftUI instrument to find the views in your app that update the most:
https://swiftdevjournal.com/posts/swiftui-frequent-view-updates/
#SwiftUI #Xcode
27.02.2026 19:32
π 1
π 0
π¬ 0
π 0
Original post on mastodon.world
I tried using SwiftUI's new support for rich text in TextEditor. It's nowhere near a replacement for NSTextView on Mac.
You have to open the ruler from the Format menu to show rich text formatting controls. The controls are limited compared to NSTextView's inspector.
The worst issue is [β¦]
19.02.2026 18:55
π 0
π 0
π¬ 1
π 0
Original post on mastodon.world
SwiftUI instrument tip: take the following steps to find the code causing long updates:
1. Right-click on a red or orange bar in the graph.
2. Choose Set Inspection Range.
3. Switch to the Time Profiler instrument.
4. Hide System Libraries.
5. Double-click a function to see the lines of code [β¦]
12.02.2026 19:29
π 1
π 0
π¬ 0
π 0
Profiling Swift Apps Book Β· Swift Dev Journal
If you have trouble figuring out what Instruments is reporting, my Profiling Swift Apps book can help.
https://swiftdevjournal.com/instruments-book/ https://mastodon.social/@alexsteinerde/116029192259707294
09.02.2026 19:22
π 0
π 0
π¬ 0
π 0
Supporting SwiftUI Sidebar Selection with Multiple Data Types
When handling the sidebar selection in a SwiftUI app, the usual approach is to add a `@State` property to the view to store the selection. The code looks similar to the following code:
@State private var selection: Chapter? = nil
The usual approach works well if all the items in the sidebar have the same data type. What do you do if the sidebar items have different data types?
Supporting selection with multiple data types involves the following tasks:
* Create an enum for the sidebar selection.
* Use the enum you create as the data type for the selection.
* Add a `.tag` modifier to each list item that holds the itemβs data type and value.
## Creating the enum
Create an enum for the sidebar selection with a case for each possible data type a sidebar item can have.
As an example Iβm going to show code for an app Iβm currently making, a Mac GUI client for the Jujutsu version control system. The appβs sidebar has multiple items for controlling what appears in the list of changes (commits). The selection can be either a change category (all changes, mutable changes, my changes) or a bookmark (branch). Selecting a bookmark shows its changes.
The following code shows the enum for the sidebar selection:
enum SidebarSelection: Hashable, Sendable {
case change(category: ChangeCategory)
case bookmark(bookmark: Bookmark)
}
enum ChangeCategory: CaseIterable {
case allChanges
case mutableChanges
case myChanges
func stringValue() -> String {
switch(self) {
case .allChanges:
return "All Changes"
case .mutableChanges:
return "Mutable Changes"
case .myChanges:
return "My Changes"
}
}
}
struct Bookmark: Equatable, Hashable, Codable, Sendable {
// Other properties removed for clarity.
var name: String
static func == (lhs: Bookmark, rhs: Bookmark) -> Bool {
lhs.name == rhs.name
}
}
## Using the enum for the selection
In the sidebar view, add a property to store the selection. The data type is the enum you created.
@State private var selection: SidebarSelection?
## Adding the .tag modifier
Each list item in the sidebar needs a `.tag` modifier so SwiftUI knows what the item represents. The value of the modifier is one of the sidebar selection enumβs cases. You must also supply any additional data the enum case requires.
The following code shows a sidebar list with sections for change categories and bookmarks:
List(selection: $selection) {
Section(header: Text("Changes")) {
ForEach(ChangeCategory.allCases, id:\.self) { category in
Text(category.stringValue())
.tag(SidebarSelection.change(category: category))
}
}
Section(header: Text("Bookmarks")) {
ForEach(bookmarks, id:\.name) { bookmark in
Text(bookmark.name)
.tag(SidebarSelection.bookmark(bookmark: bookmark))
}
}
}
The following article shows how to support SwiftUI sidebar selection when the sidebar has multiple types of items:
https://swiftdevjournal.com/posts/sidebar-selection/
#SwiftUI
05.02.2026 18:51
π 2
π 0
π¬ 0
π 0
Objectively Better, Observably Trickier
The Observation Framework is great... once you figure out how it actually works
The following article talks about problems you may encounter when converting existing code from ObservableObject to the Observation framework :
https://captainswiftui.substack.com/p/objectively-better-observably-trickier
#SwiftUI
04.02.2026 19:53
π 2
π 0
π¬ 0
π 0
TIL: the URL NSSavePanel returns for a folder does not include a trailing slash while SwiftUI's fileImporter includes the trailing slash.
#MacDev
03.02.2026 20:54
π 2
π 0
π¬ 1
π 0
Original post on mastodon.world
Instruments tip: take the following steps to find the code in your app causing a hang:
1. Right-click on the hang in the graph
2. Choose Set Inspection Range to focus on the hang
3. Switch to the Time Profiler instrument
4. Click the Call Tree button at the bottom of the window
5. Select the [β¦]
30.01.2026 18:54
π 0
π 0
π¬ 0
π 0
Find the SwiftUI Views that Update the Most Using Instruments Β· Swift Dev Journal
The following article shows how to use the new SwiftUI instrument to find the views in your app that update the most:
https://swiftdevjournal.com/posts/swiftui-frequent-view-updates/
#SwiftUI #Xcode
26.01.2026 18:57
π 1
π 1
π¬ 0
π 0
Original post on mastodon.world
SwiftUI instrument tip: take the following steps to find the code causing long updates:
1. Right-click on a red or orange bar in the graph.
2. Choose Set Inspection Range.
3. Switch to the Time Profiler instrument.
4. Hide System Libraries.
5. Double-click a function to see the lines of code [β¦]
22.01.2026 18:57
π 1
π 0
π¬ 0
π 0
Reducing the Number of .sheet Modifiers in Your SwiftUI Views Β· Swift Dev Journal
If you find that your SwiftUI views have too many .sheet modifiers, the following article shows a way to reduce the number of modifiers:
https://swiftdevjournal.com/posts/reducing-sheet-modifiers/
#SwiftUI
20.01.2026 19:03
π 2
π 1
π¬ 0
π 0
Supporting SwiftUI Sidebar Selection with Multiple Data Types
When handling the sidebar selection in a SwiftUI app, the usual approach is to add a `@State` property to the view to store the selection. The code looks similar to the following code:
@State private var selection: Chapter? = nil
The usual approach works well if all the items in the sidebar have the same data type. What do you do if the sidebar items have different data types?
Supporting selection with multiple data types involves the following tasks:
* Create an enum for the sidebar selection.
* Use the enum you create as the data type for the selection.
* Add a `.tag` modifier to each list item that holds the itemβs data type and value.
## Creating the enum
Create an enum for the sidebar selection with a case for each possible data type a sidebar item can have.
As an example Iβm going to show code for an app Iβm currently making, a Mac GUI client for the Jujutsu version control system. The appβs sidebar has multiple items for controlling what appears in the list of changes (commits). The selection can be either a change category (all changes, mutable changes, my changes) or a bookmark (branch). Selecting a bookmark shows its changes.
The following code shows the enum for the sidebar selection:
enum SidebarSelection: Hashable, Sendable {
case change(category: ChangeCategory)
case bookmark(bookmark: Bookmark)
}
enum ChangeCategory: CaseIterable {
case allChanges
case mutableChanges
case myChanges
func stringValue() -> String {
switch(self) {
case .allChanges:
return "All Changes"
case .mutableChanges:
return "Mutable Changes"
case .myChanges:
return "My Changes"
}
}
}
struct Bookmark: Equatable, Hashable, Codable, Sendable {
// Other properties removed for clarity.
var name: String
static func == (lhs: Bookmark, rhs: Bookmark) -> Bool {
lhs.name == rhs.name
}
}
## Using the enum for the selection
In the sidebar view, add a property to store the selection. The data type is the enum you created.
@State private var selection: SidebarSelection?
## Adding the .tag modifier
Each list item in the sidebar needs a `.tag` modifier so SwiftUI knows what the item represents. The value of the modifier is one of the sidebar selection enumβs cases. You must also supply any additional data the enum case requires.
The following code shows a sidebar list with sections for change categories and bookmarks:
List(selection: $selection) {
Section(header: Text("Changes")) {
ForEach(ChangeCategory.allCases, id:\.self) { category in
Text(category.stringValue())
.tag(SidebarSelection.change(category: category))
}
}
Section(header: Text("Bookmarks")) {
ForEach(bookmarks, id:\.name) { bookmark in
Text(bookmark.name)
.tag(SidebarSelection.bookmark(bookmark: bookmark))
}
}
}
The following article shows how to support SwiftUI sidebar selection when the sidebar has multiple data types:
https://swiftdevjournal.com/posts/sidebar-selection/
#SwiftUI
16.01.2026 20:04
π 2
π 0
π¬ 1
π 0
Original post on mastodon.world
Instruments tip: take the following steps to find the code in your app causing a hang.
1. Right-click on the hang in the graph
2. Choose Set Inspection Range to focus on the hang
3. Switch to the Time Profiler instrument
4. Click the Call Tree button at the bottom of the window
5. Select the [β¦]
14.01.2026 18:50
π 0
π 1
π¬ 0
π 0
Original post on mastodon.world
Do you have performance problems in your app, such as the app running slow or using tons of memory? Do you struggle to find the cause of those problems?
If you answered Yes to both questions, my Profiling Swift Apps book can help. The book shows you how to use Instruments to find performance [β¦]
13.01.2026 20:01
π 2
π 0
π¬ 0
π 0