Swift Dev Journal
banner
swiftdevjournal.mastodon.world.ap.brid.gy
Swift Dev Journal
@swiftdevjournal.mastodon.world.ap.brid.gy
I develop Mac and iOS apps (Phel, Bartleby, AM Pages, Rija) in Swift using SwiftUI and AppKit. I also write about app development in Swift at Swift Dev […]

[bridged from https://mastodon.world/@swiftdevjournal on the fediverse by https://fed.brid.gy/ ]
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 […]
Original post on mastodon.world
mastodon.world
November 13, 2025 at 7:53 PM
The following article provides a nice introduction to using Swift arrays:

https://bugfender.com/blog/swift-arrays/

#Swift
Swift Arrays: Map, Filter, Reduce & Sort Explained
In Swift, arrays enable us to sort, filter and transform our data efficiently. In fact, they’re among the most powerful
bugfender.com
November 10, 2025 at 8:37 PM
If you are getting unexpected behavior when running a Terminal command using the Process class, make sure you call waitUntilExit after calling the run function.

I had an issue in a SwiftUI app where selecting an item from a list caused multiple copies of the item to be created and selected. The […]
Original post on mastodon.world
mastodon.world
November 7, 2025 at 7:51 PM
The following article shows how to use the new SwiftUI instrument in Xcode 26 to find the SwiftUI views that update the most in your app and see what triggers view updates:

https://swiftdevjournal.com/posts/swiftui-frequent-view-updates/

#swiftui #Xcode
Find the SwiftUI Views that Update the Most Using Instruments
When profiling a SwiftUI app with Instruments, one thing you want to know is what views update the most. If a view updates more than you expect, you want to know what causes the updates. In this article you will learn how to use the SwiftUI instrument to find the views in your app that update the most and find what triggers view updates. This article uses the new SwiftUI instrument Apple added in Xcode 26. If you are using an earlier version of Xcode, read the following article: See How Many Times Your SwiftUI Views Redraw Using Instruments ## Profile your app Take the following steps to profile your app with the SwiftUI instrument: 1. Go to Xcode. 2. Press Cmd-I or choose Product > Profile to build your project and launch Instruments. 3. Choose SwiftUI from the template list. 4. Click the Choose button. 5. Click the Record button above the sidebar to start profiling. 6. Click the Stop button when you are finished. ## Find the views that update the most Use the all updates summary to find the views that update the most. Instruments should show the all updates summary when you stop profiling, but if you don’t see it in the detail view, press Cmd-1 or choose Summary: All Updates from the jump bar menu. The SwiftUI instrument’s all updates summary shows the following statistics for the views in your app: * Number of updates * Total update time * Shortest update * Longest update * Average update time Take the following steps to find the views that update the most: 1. Click the disclosure triangle next to the name of your app to see the app’s modules. 2. Click the disclosure triangle next to your app’s module to see a list of your app’s views. 3. Click the Count column heading to sort the views by update count so you can see what views update the most. ## Find what causes a view to update Use the cause and effect graph in the SwiftUI instrument to find the cause of view updates. Take the following steps to show the cause and effect graph for a view: 1. Move the pointer over a view in the all updates summary. 2. Click the small button that appears next to the name of the view. 3. Choose Show Cause & Effect Graph. The cause and effect graph looks similar to the following screenshot: The graph consists of a collection of nodes with arrows showing the flow of events. Graph nodes for your code are blue. System-defined nodes are gray. Initially the graph is focused on the view you selected from the summary. The nodes to the left of the view show the events that trigger the view update. The nodes to the right of the view show the effects of the view update. To figure out what triggers an update, move left along the graph until you find other blue nodes. The most common cause of view updates is data updates. When the data the view shows changes, the view updates. If you are not seeing any nodes to the left of a particular node, move the pointer over the node to show one or two buttons at the top of the node. Clicking the left button toggles showing and hiding the nodes to the left of the selected node. If no buttons appear, you reached the end of a path. ## Do you want to learn more about the SwiftUI instrument? I wrote a book, _Profiling Swift Apps_ , that shows you how to use Instruments to find and fix problems in your code. The book has a chapter on using the SwiftUI instrument to find problems in your SwiftUI code. You can learn more about the book and download a sample at the following link: Profiling Swift Apps page
swiftdevjournal.com
November 7, 2025 at 6:32 PM
Instruments tip for the curious: to see all the data Instruments recorded, press Cmd-I or choose View > Show Recorded Data.

#Xcode
November 6, 2025 at 7:15 PM
I ran into a problem where a Mac app project was crashing on startup due to a selection string range error in an unsaved document. Cleaning the build folder didn't fix the problem.

The fix was to go into the ~/Library folder in the Finder, search for the name of the app, and move the unsaved […]
Original post on mastodon.world
mastodon.world
November 4, 2025 at 7:34 PM
Reposted by Swift Dev Journal
I gave my first ever conference talk at PyCon AU in Sept, based on my book: Escape from Tutorial Hell. It uses Swift and macOS in all its examples, but the principles apply to all languages.

I offered a 25% discount to all conference goers but not all the QR […]

[Original post on mastodon.social]
November 3, 2025 at 5:22 AM
I released an update to my Instruments book that adds a chapter on using the new SwiftUI instrument Apple added in Xcode 26.

The update is free for everyone who bought the book. You can learn more about the book at the following link:

https://swiftdevjournal.com/instruments-book/

#Xcode
Profiling Swift Apps Book · Swift Dev Journal
swiftdevjournal.com
November 3, 2025 at 5:17 PM
The following article shows how to use Instruments to find the slow spots in your app's code:

https://swiftdevjournal.com/posts/cpu-profiler/

#Xcode
Find the Slow Spots in Your Code with the CPU Profiler Instrument · Swift Dev Journal
swiftdevjournal.com
October 31, 2025 at 6:21 PM
If you're using Instruments with Xcode 26.0, I recommend installing Xcode 26.1.

Xcode 26.1 fixes a bug where the call tree view shows functions from system libraries when you select the Hide System Libraries and Invert Call Tree checkboxes.

#Xcode
October 29, 2025 at 6:32 PM
Reposted by Swift Dev Journal
I'm proud to announce v1.0 of ✨Interfazzle✨, my wee #swift #cli tool that builds #markdown documentation for a package's public interface from symbol graphs.

My reason for making it: I really don't like DocC. DocC and its dynamic-page output is the Liquid Glass of documentation. (There, I said […]
Original post on norden.social
norden.social
October 29, 2025 at 12:26 PM
The following article shows how to create a custom URL scheme handler for SwiftUI apps:

https://useyourloaf.com/blog/swiftui-custom-url-schemes/

#swiftui
SwiftUI Custom URL Schemes
Create a custom URL scheme handler for SwiftUI WebViews
useyourloaf.com
October 28, 2025 at 6:49 PM
The following article provides an introduction to reading the flame graph in Instruments:

https://swiftdevjournal.com/posts/instruments-flame-graph-intro/

#Xcode
Instruments Flame Graph Introduction · Swift Dev Journal
swiftdevjournal.com
October 24, 2025 at 5:41 PM
The following article provides a nice introduction to Swift enums:

https://bugfender.com/blog/swift-enums/

#Swift
Swift Enums: Write Better, Safer, and Cleaner Code
Swift enums are among Swift’s most powerful tools, adding structure, safety, and clarity to code that often leans on messy
bugfender.com
October 21, 2025 at 7:19 PM
The following article provides some nice examples of creating toolbars in SwiftUI Mac apps:

https://ohanaware.com/swift/macOSToolbarExamples.html

#swiftui #macdev
SwiftUI macOS Toolbar examples - Ohanaware.com
Simple examples of the various kinds of macOS Toolbars you can create with SwiftUI.
ohanaware.com
October 20, 2025 at 4:17 PM
The following article provides an introduction on supporting rich text editing with SwiftU's TextEditor view:

https://www.createwithswift.com/using-rich-text-in-the-texteditor-with-swiftui/

#swiftui
Using rich text in the TextEditor with SwiftUI
Explore the usage of rich text within the TextEditor in SwiftUI using AttributedString.
www.createwithswift.com
October 17, 2025 at 6:07 PM
If you're wondering where to find the Library in Xcode 26 so you can access code snippets and storyboard UI elements, choose View > Show Library in Xcode or press Cmd-Shift-L.

#Xcode
October 16, 2025 at 6:04 PM
The following article shows how to use Instruments to find the slow spots in your app's code:

https://swiftdevjournal.com/posts/cpu-profiler/

#Xcode
Find the Slow Spots in Your Code with the CPU Profiler Instrument · Swift Dev Journal
swiftdevjournal.com
October 13, 2025 at 8:16 PM
The following article shows how to run a command-line program from inside a Mac GUI app:

https://swiftdevjournal.com/running-a-command-line-program-from-a-mac-app/

#macdev
Running a Command-Line Program from a Mac App · Swift Dev Journal
swiftdevjournal.com
October 9, 2025 at 6:53 PM
The following article shows how to support search in a SwiftUI app that uses SwiftData:

https://www.createwithswift.com/performing-search-with-swiftdata-in-a-swiftui-app/

#swiftdata #swiftui
Performing search with SwiftData in a SwiftUI app
Learn how to combine SwiftData queries with the seachable modifier on SwiftUI.
www.createwithswift.com
October 8, 2025 at 4:05 PM
Time Profiler instrument tip: click the Self Weight column heading to bring the functions where your app spends the most time to the top of the call tree view.

If you want to learn more about Instruments, check out my book Profiling Swift Apps. You can learn more about the book at the following […]
Original post on mastodon.world
mastodon.world
October 6, 2025 at 7:15 PM
The following article shows how to open document-like windows using SwiftUI's WindowGroup:

https://swiftdevjournal.com/posts/swiftui-window-group/

#swiftui
Open Document-like Windows Using SwiftUI WindowGroup · Swift Dev Journal
swiftdevjournal.com
October 3, 2025 at 6:53 PM
Are you not sure how to use the flame graph in Instruments? The following article should help you get started with the flame graph:

https://swiftdevjournal.com/posts/instruments-flame-graph-intro/

#Xcode
Instruments Flame Graph Introduction · Swift Dev Journal
swiftdevjournal.com
September 30, 2025 at 4:24 PM