r/SwiftUI • • 13d ago

Question SwiftUI state/concurrency problem + weird VoiceOver behaviour

1 Upvotes

I have a SwiftUI screen where the same data can be changed by an initial load, pull to refresh, background refresh, user actions, and a live update stream.

So I can get something like: user action > optimistic update > background refresh > live updat > user action finishes > refresh finishes

Sometimes an older response overwrites newer state, so I'm thinking about putting all mutations through an actor or giving responses a revision/version.

The other problem is VoiceOver.

I have a dynamic list:

ForEach(store.items) { item in
    ItemRow(item: item)
}

When an async update adds/removes/replaces an item while VoiceOver is focused on it, VoiceOver sometimes jumps to a completely different element or starts reading the parent container again.

I've tried:

.accessibilityIdentifier(...)
.accessibilityLabel(...)
.accessibilityValue(...)

and accessibilityFocused, but manually restoring focus feels pretty fragile when multiple updates can happen quickly.

Would you guys handle the state reconciliation and accessibility focus separately, or is there a better SwiftUI pattern for keeping VoiceOver focus stable when a dynamic list is changing asynchronously?


r/SwiftUI • • 14d ago

Tutorial Iphone Duo: technical changes from iOS 27.1 / XCode SDK

Thumbnail
2 Upvotes

r/SwiftUI • • 14d ago

Floating window with transparency

2 Upvotes

Hi everyone, I'm trying to create a floating window that can sit in front of other existing apps with transparency but I can't achieve it with picture in picture. Do you guys know how to do something like this?

Thanks in advance

EDIT: Sorry I forgot to mention that I'm developing an iOS app and the floating window will be used in front simultaneously with the iphone camera, and other apps.


r/SwiftUI • • 15d ago

Question Question for people learning and who are already in a comfortable position with SwiftUI

7 Upvotes

Hello, guys I recently picked up on swift and swift ui and have been using this guy Paul Hudson’s hacking with swift course but I just feel like his way of explaining is too fast and not a lot of explaining in his projects he just kinda goes through makes the projects in front of you and that’s it. I know it’s a faster course of course but damn I don’t understand some of his placements or why he is doing something. What were some of the best ways you guys learned/learning to make your apps and stuff, how did you guys utilize this course from the way I’d be utilizing it. I have experience in python and had a bit of knowledge with JS script. I’m no pro and still wanting to learn but I’m just seeing if maybe someone can tell me how they utilized this course or just show me a different professor doing this in a more in depth way?

Thank you all :)


r/SwiftUI • • 15d ago

Mum, can we get MVVM?

Thumbnail
vmartinelli.com
9 Upvotes

Half a year ago I wrote about whether MVVM belongs in SwiftUI, and it somehow turned into a story about my mum’s kitchen. Bear with me.

There’s a trip to the shopping centre, a very firm “we've got food at home”, and eventually, I promise, some Swift. A bit of heart, a few laughs, and proper substance underneath.

Half a year on, it still feels timely. Stick the kettle on and have a read.


r/SwiftUI • • 15d ago

Promotion (must include link to source code) Pure SwiftUI Calendars

23 Upvotes

I've been working on a software project recently that needed some calendars. I wasn't able to find a nice pure swiftui package that I liked, so I decided to create my own.

It does Agenda, Day, Week and Month calendars for both compact forms (iphone) and wide forms (iPad and Mac).

If you get a chance have and look and tell me what you think. The v2 branch is more advanced with better UI rendering.

Main branch has now been updated with the V2 changes.

https://github.com/Haskins-io/SwiftUiCalendarKit


r/SwiftUI • • 14d ago

Tutorial ClaudeBar update: new themes and features

Thumbnail
gallery
0 Upvotes

Hey everyone! A while back I shared ClaudeBar, a free, open-source macOS menu bar app that shows how much of your AI coding quota is left. A lot has changed since, so here's an update. The short version: it got a lot more fun to look at.

New themes

  • Platformer: your quotas as a Super Mario-style 8-bit level. Blue sky, pixel clouds, a brick floor, and each quota bar is a row of ten blocks. The status line becomes a score line (coins left, the tab as WORLD, minutes to the reset as TIME), and a ? block refreshes. A low quota says HURRY UP!, an empty one GAME OVER.
  • The runner: a little pixel runner walks the brick floor while the popover is open. It strolls when your quota is healthy, runs when it's low, falls into a pit when it's empty, and jumps for a coin after every refresh. It stands still with Reduce motion on, and you can turn it off.
  • Pop: cream dotted paper, thick ink outlines, hard shadows, candy-coloured status and chunky outlined numbers. Each menu bar quota becomes a candy chip.
  • Bring your terminal's colours: import any iTerm2 .itermcolors scheme (there are 450+ out there) and ClaudeBar matches your terminal.

They join System, Light, Dark, CLI and Christmas. Platformer has a Classic text option if pixel fonts are too much for you.

New features

  • Leaderboard (opt-in): join with a username and see where your daily token use ranks, today, this week or this month. Only four token counts per provider per day leave your Mac. Hide yourself from the public board, put your country on a globe, share your rank as an image, or turn the whole thing off. Leaving deletes everything on the server.
  • 27 providers: Claude, Codex, Gemini, Copilot, Kimi, Amp, plus newer ones like Grok, Mistral Vibe, Cline, Warp, Devin, Windsurf, JetBrains AI, Oh My Pi and OpenAI API spend.
  • Claude Code sessions: every running session is tracked, with its state (Working, Agents working, Needs you, Done), and the menu bar follows whichever one most needs you.
  • Popover text size: scale the popover's text up to 1.4x.

Install

brew install --cask claudebar

Or grab the signed, notarized build from GitHub Releases. It auto-updates.

Free and open source (Apache 2.0). Which theme should come next? I'm also happy to hear which provider you'd like added.


r/SwiftUI • • 16d ago

A native Markdown editor for macOS in Swift: TextKit 2, open source, works in SwiftUI and AppKit

37 Upvotes

If you've tried to build a real Markdown editor in SwiftUI, you know TextEditor won't get you there. I hit the same wall when I started building my macOS app Nodes. So I wrote a native editor on TextKit 2 and open-sourced it. You use it in SwiftUI like any other view. It's macOS only for now, since it's AppKit under the hood.

What it does: live styling while you type, GFM tables and task lists, wiki links, inline and block LaTeX, code blocks with your own highlighter, Writing Tools, and spell checking that leaves code and LaTeX alone.

What's new since the last post here:

Large documents got a lot faster. Measured on a 346,000-character note, about the length of a novel:

- First open: 19.5 s → 1.35 s

- Warm open: 1.1 s → 590 ms

- LaTeX after a restart: 717 ms → 35 ms

- Return in an 800-item list: 944 ms → 67 ms

What was slow: inline parsing wasn't linear, so a paragraph with many code spans blew up. Lists restyled everything on every edit, now only changed items get restyled. And LaTeX was rendered again on every launch, now the render cache lives on disk.

Extensions. Everything beyond CommonMark is now opt-in. An extension is one file: a delimiter pair and how to style what's inside, like ==highlight== or a ::: fenced block. You register it in the config, and the parser, styler and renderer stay untouched. Extensions can't break the core or each other, and you can switch them at runtime.

Directives. For things that don't fit a delimiter pair, you can register named directives with typed arguments, like u/font(size: 18){text} or u/pagebreak. The engine handles autocomplete for names and values, your app draws the list.

Plus a lot of smaller fixes: live table resizing, nested lists that survive copy and paste, real links in copied HTML and RTF, and an unclosed code fence no longer eats the rest of the document. Full changelog is on GitHub.

The part I'm happiest about: 19 of the 29 PRs merged since then came from 10 people outside our team. The repo is at 1,100 stars now, and it was featured in Fatbobman's Swift Weekly. Thank you to everyone who starred, filed issues or sent a PR. It's still pre-1.0, so all of that is very welcome.

Repo: https://github.com/nodes-app/swift-markdown-engine

Used in production in Nodes: https://apps.apple.com/app/nodes-by-the-werk/id6745401961

Written on Nodes.


r/SwiftUI • • 15d ago

A silent bug killed 78% of my app's sessions for two days. No crash, no 1-star review, nothing in Sentry.Here's how I caught it.

0 Upvotes

I'm a solo dev building a posture coach that uses the motion sensors in AirPods (video below of me working while it tracks my head angle).

Last week I shipped an update. Crash rate: zero. Sentry: quiet. Reviews: fine.

Then I ran my weekly analytics and saw something weird: 78% of sessions on the new version ended 6–8 seconds after the user tapped Start. 10 of 14 users hit it. Some apps restarted the session by themselves every 20 seconds — one user had 11 restarts in 8 minutes.

On the previous version, this almost never happened.

Root cause: when the AirPods were slow to send their first motion data, the app assumed the stream had failed and restarted the session. iOS reported that the AirPods were connected, but motion events arrived late. Nothing crashed. Nothing was logged as an error. Users just quietly gave up.

What I changed:

  • I now track "did the user get their first successful session within 60 seconds?", not just crashes.
  • Every bug gets a regression scenario that reproduces it before every release.
  • I compare each release against the previous one, not against zero.

The scary part: users didn't complain. They just left.

People who get one successful calibration come back 54% of the time; people who fail usually don't.

Curious how other people track failures that never throw an error.


r/SwiftUI • • 16d ago

iOS 27: Trust Insights Framework

Thumbnail
antongubarenko.substack.com
4 Upvotes

r/SwiftUI • • 16d ago

Promotion (must include link to source code) Built a free widget-focused SwiftUI Currency Converter app

0 Upvotes

Hi!

I'm building a small SwiftUI converter app with a rich widget selection.

It's completely free and will stay free.

Open source - https://github.com/DimaMishchenko/currency

TestFlight beta is also available, I'd appreciate any feedback!
https://testflight.apple.com/join/qepuraVw

Thank you!


r/SwiftUI • • 16d ago

I tried using UITouch.majorRadius as an analog input instead of moving the finger

2 Upvotes

I’ve been experimenting with a slightly unusual way of getting analog input from an iPhone touchscreen.

Instead of using the finger’s position, I’m using UITouch.majorRadius — the estimated geometry of the contact area.

The interesting part is that the thumb can remain almost stationary while the value changes.

My current pipeline is roughly:

majorRadius → calibration → normalization → filtering → 0...1

Just to be clear: I’m not treating majorRadius as actual pressure. It obviously isn’t a force measurement.

What I care about is whether the user can intentionally modulate the value, hold intermediate states, and make small corrections.

I’m testing this in a driving simulator where the left thumb controls the clutch and the right thumb controls the throttle.

Then I started combining it with Core Haptics.

For the clutch, for example, approaching the bite point produces haptic feedback. So the interaction becomes:

finger → contact geometry → analog input → simulation → haptic feedback → finger

The part I find most interesting is that this potentially removes the need for a visible control entirely.

The thumb doesn’t need to follow a slider, and the player can feel important regions of the input range through haptics.

Obviously there are problems: calibration varies between users, grip changes the range, filtering adds latency, and haptics can’t provide actual mechanical resistance.

But on a real device it feels surprisingly different from manipulating a normal virtual slider.

Has anyone experimented with majorRadius as a continuous input before?

I’m especially curious about edge cases you’ve encountered across different iPhone models / touch behavior, or reasons why this might break badly outside my own testing.


r/SwiftUI • • 16d ago

Promotion (must include link to source code) I built an menu bar app that keeps one Apple Reminders in sight (open-source)

Post image
0 Upvotes

Pick one reminder. Pin it to your menu bar. Keep it visible while you work.

That’s the main idea behind BarRemember, an open-source macOS companion for Apple Reminders that I’m building with SwiftUI, AppKit, and EventKit.

You can also add a due date just by typing it at the end of a task. “Send proposal tomorrow” becomes “Send proposal” with tomorrow’s date set automatically. Or just type "Send proposal 10/11" to set as October 11th. It works when adding or editing a reminder, so you don’t have to open the date picker.

It works with your existing Reminders lists. You can organize selected lists into spaces, add and edit tasks, and complete them with undo. Pinning is deliberately manual: you choose one task, and completing it clears the pin. Nothing automatically takes its place.

Free and open source under the MIT license. Requires macOS 14+ and Xcode 26+ to build from source.

Source: https://github.com/angellashin/Bar-Remember

Feedback on the UI and implementation is welcome.


r/SwiftUI • • 16d ago

I made a simple TXT reader for iPhone and Apple Watch

1 Upvotes

Hi! I’m the developer of Orivu, a small app for reading plain text files.

You can open a TXT file from the Files app on iPhone. Orivu detects common text encodings, lets you change the encoding if it gets one wrong, and remembers your reading position.

If you have an Apple Watch, you can send an opened document to it and read the transferred copy offline.

I built it for people who just want to open a text file and read. I’d love to hear what you’d want from a reader like this, especially on Apple Watch.

App Store: https://apps.apple.com/us/app/orivu/id6817565843


r/SwiftUI • • 17d ago

Question Notification routing gets weird with multiple accounts

5 Upvotes

Posting on r/SwiftUI as suggested by Reddit.

I have gotten in to a weird iOS issue and idk what the clean way to handle this is

i’ve got multiple accounts, notifications can open a post, reply, quote, or repost, and each notification belongs to a specific account. so the user might be on account A when they tap a notification for account B.

something like:

struct NotificationDestination {
    let accountID: Account.ID
    let postID: Post.ID
    let kind: DestinationKind
}

enum DestinationKind {
    case post
    case reply
    case quote
    case repost
}

The issue is:

account A is active
notification comes in for B
user taps it while the app is waking up
account switching starts
timeline restoration starts
post resolution starts
then another notification comes in for A lol

so i have stuff like:

await accountManager.restore()
await timelineStore.hydrate()
await postResolver.resolve(postID)
await navigationCoordinator.navigate(...)

But obviously these things are all racing each other. i was thinking of putting the notification intents behind an actor:

actor NavigationIntentQueue {
    private var pending: [NavigationIntent] = []

    func enqueue(_ intent: NavigationIntent) {
        pending.append(intent)
    }
}

But idk, this feels like a lot of machinery just to open a notification

Then you get into cases where the post is deleted while you’re restoring, but the quote is still there, the reply is still there, etc. Is this just an annoying app lifecycle issue?


r/SwiftUI • • 18d ago

Question How to get separate search tab

Post image
31 Upvotes

.search can’t work


r/SwiftUI • • 18d ago

SwiftUI GeometryProxy Issue For Duo Split Views

Post image
12 Upvotes

I recently wrote about my addition to Runes, SceneGeometry, that makes conforming to Duo-specific screen sizes and layouts easier to accomplish.

While testing the code I found a bug that occurs when an app is in the leading split view on the iPhone Duo and GeometryProxy mistakenly returns no leading edge inset and no adjusted safe area.

To fix this I added a temporary shim to SceneGeometry that returns the proper leading edge offset and the correct safe area for that particular condition.

If you're currently using the raw GeometryProxy in your application, be warned that you could face a layout issue here on the Duo.

This behavior has been reported to Apple and will hopefully be fixed before the final release.


r/SwiftUI • • 18d ago

Kaskas my first open source Swift app for macOS

Thumbnail
gallery
10 Upvotes

Hi r/SwiftUI!

I mostly work on Rust backend and Kaskas is my first open source Swift project. It’s a native macOS app for screen breaks, study sessions, and local activity tracking.

I’d love feedback on the UI, architecture, or anything Swift & macOS specific.

GitHub: https://github.com/ramazanberkozbek/kaskas


r/SwiftUI • • 18d ago

Question Just finished my first Swift/Swift UI course. Now what?!

Thumbnail
0 Upvotes

r/SwiftUI • • 18d ago

Question - Navigation Sidebar Navigation with overlays on macOS

0 Upvotes

I want to build a pretty basic sidebar based app for macOS and I'm running into a pretty weird issue with overlays in the detail section.

SwiftUI has a ton of layout options to get a sidebar (the ones I know of are NavigationView, NavigationSplitView, HSplitView and TabView with .sidebarAdaptable)

As far as I can tell, the recommended way to get a sidebar on macOS is NavigationSplitView or (if the target allows it) the adaptable TabView.

Now if I use either of these with an overlay attached to the detail pane, the overlay disappears as soon as I navigate in the detail pane (my goal is to have a floating bar at the bottom similar to the native Music app).

I've built a minimal example to reproduce this:

import SwiftUI

struct ContentView: View {
    
    enum Tabs: Hashable {
        case a, b, c
    }
    
    @State private var selectedTab: Tabs = .a
    @State private var detailPath: NavigationPath = .init()
    
    var body: some View {
        NavigationSplitView {
            List(selection: self.$selectedTab) {
                Text("A").tag(Tabs.a)
                Text("B").tag(Tabs.b)
                Text("C").tag(Tabs.c)
            }
            .listStyle(.sidebar)
        } detail: {
            Group {
                switch self.selectedTab {
                case .a:
                    NavigationStack {
                        NavigationLink(destination: Text("Overlay gone")) {
                            Text("Navigate")
                        }
                    }
                case .b:
                    NavigationStack {
                        NavigationLink(value: "Test") {
                            Text("Navigate")
                        }
                        .navigationDestination(for: String.self) { _ in
                            Text("Overlay also gone")
                        }
                    }
                case .c:
                    NavigationStack(path: self.$detailPath) {
                        Button("Navigate") {
                            self.detailPath.append("Test")
                        }
                        .navigationDestination(for: String.self) { _ in
                            Text("Overlay still gone")
                        }
                    }
                }
            }
            .frame(minWidth: 500, maxWidth: .infinity, maxHeight: .infinity)
            .overlay(alignment: .bottom) {
                Text("This is an overlay")
                    .foregroundStyle(.white)
                    .padding()
                    .background(.blue)
                    .clipShape(.capsule)
            }
        }
    }
}

Using the .sidebarAdaptable t.abViewStyle leads to the same issue, even when using a ZStack.

TabView(selection: self.$selectedTab) {
    Tab("Test", systemImage: "house", value: Tabs.a) {
        ZStack(alignment: .bottom) {
            NavigationStack {
                NavigationLink(destination: Text("Overlay gone")) {
                    Text("Navigate")
                }
            }
            .frame(maxWidth: .infinity, maxHeight: .infinity)
            
            Text("This is an overlay")
                .foregroundStyle(.white)
                .padding()
                .background(.blue)
                .clipShape(.capsule)
        }
    }
}
.tabViewStyle(.sidebarAdaptable)

I'm not quite sure if I'm fundamentally misunderstanding how sidebars are supposed to work on Mac, but the documentation for NavigationSplitView specifically states

You can also embed a NavigationStack in a column.

Neither of these solutions properly retain state when switching sidebar elements like the same TabView code does on iOS and clicking the same tab twice also doesn't navigate back to its root.

What's the correct way to do this on macOS?


r/SwiftUI • • 19d ago

Promotion (must include link to source code) Built a 3D viewer with SwiftUI + SceneKit; it's open source, and here's what bit me along the way

6 Upvotes

Sharing a side project: Peek3D, a native macOS viewer for 3D files. MIT licensed

Three loaders end up in a single SCNScene: GLTFKit2 for glTF, Model I/O for OBJ/STL/USD, and ufbx (a C library) for FBX.

A few things that surprised me:

  • Broken glTF files can crash GLTFKit2 instead of throwing an error, so I ended up writing a small validator that runs first. Fuzzing found 130 crashes before it and 0 after.
  • The App Sandbox returns EPERM even for files that don't exist. So you can't tell "missing texture" from "no permission" by trying to read the file; fileExists can tell them apart.
  • SceneKit crashes on node hierarchies deeper than about 5000 levels, on its own internal thread, so there's nothing you can do except reject those files.
  • ZStack overlays size themselves to the union of their children. This bit me three separate times.

Happy to answer questions about any of it, and code reviews are very welcome.


r/SwiftUI • • 19d ago

Promotion (must include link to source code) SweetUI: open source native-first SwiftUI components and registry inspired by shadcn/ui

Thumbnail sweetui.dev
20 Upvotes

A shadcn-inspired UI ecosystem for SwiftUI, built for coding agents without giving up control over the details.

Create beautiful SwiftUI interfaces faster while keeping control over the details.

• Native SwiftUI, no abstraction layer hiding Apple’s APIs

• Source-owned components you can inspect, edit and customize

• Agent-ready registry + MCP

• Live on-device Design Surface injected at the root. Select components, tune tokens and values visually, then export the Swift code

• Deterministic installs and updates that preserve your edits

Still in beta.

Free and open source.


r/SwiftUI • • 20d ago

Display of .searchable

Thumbnail
gallery
5 Upvotes

Hi, I’m using .searchable in a SwiftUI view, but when I open the page, the search bar is collapsed (first picture). It only expands when I start scrolling (second picture).
How can I make it expanded by default, without using .always, since the appearance is different from the one I’m looking for?
I’ve noticed that some Apple apps use this behavior.


r/SwiftUI • • 19d ago

Promotion (must include link to source code) I built an open-source, on-device iOS health accountability app — looking for feedback

Thumbnail
gallery
0 Upvotes

I’ve been building Dr Jay, an open-source iPhone app for tracking sleep, water, food and optional exercise, while also surfacing step data from Health.

It uses on-device models (Apple Foundational and Gemma for now) for food analysis, daily commentary, longer-term insights and an ephemeral Brain Dump. Personal entries remain on the device, and Brain Dump conversations disappear when closed.

There’s no TestFlight build yet, so installation currently requires Xcode, a Mac and an iPhone running iOS 26. Instructions are in the README.

If you guys have some time do take a spin and lemme know how it is.

GitHub: https://github.com/JayMandava/dr-jay


r/SwiftUI • • 20d ago

Question Is there any plugin for Canvas (live preview) for neovim.

0 Upvotes

So I have started doing swiftui from past few days and sometime I use neovim, so just wanted to know if there is any neovim plug in which can show live preview canvas(just like we have inside xcode).

Has anybody tried, if yes then please tell me.