r/SwiftUI • u/beatpaq • 7h ago
r/SwiftUI • u/AutoModerator • Oct 17 '24
News Rule 2 (regarding app promotion) has been updated
Hello, the mods of r/SwiftUI have agreed to update rule 2 regarding app promotions.
We've noticed an increase of spam accounts and accounts whose only contribution to the sub is the promotion of their app.
To keep the sub useful, interesting, and related to SwiftUI, we've therefor changed the promotion rule:
- Promotion is now only allowed for apps that also provide the source code
- Promotion (of open source projects) is allowed every day of the week, not just on Saturday anymore
By only allowing apps that are open source, we can make sure that the app in question is more than just 'inspiration' - as others can learn from the source code. After all, an app may be built with SwiftUI, it doesn't really contribute much to the sub if it is shared without source code.
We understand that folks love to promote their apps - and we encourage you to do so, but this sub isn't the right place for it.
r/SwiftUI • u/soumyaranjanmahunt • 7h ago
Tutorial Build server-driven UI targeting
r/SwiftUI • u/everybodyhatesBacho • 8h ago
News I built Snitch, an open-source in-app inspector for network requests and analytics events (PostHog, AppsFlyer)
ZoomSlider: a SwiftUI slider that magnifies the ticks under your finger
I rebuilt this zoom-slider interaction as a SwiftUI Swift package, inspired by the work of u/kshvbgde.
Press the pill and it opens into a bubble with the full value, while the ticks under your finger spread apart so each step is easy to land on.
Dark/light styles, custom labels, haptics, VoiceOver and Reduce Motion support.
iOS 17+, MIT.
https://github.com/ismnoiet/zoom-slider-ios
Would love your feedback!
r/SwiftUI • u/yonijons • 1d ago
Swift Agentic Program 30 of November (Spanish devs only)
r/SwiftUI • u/Charming_Group_2950 • 2d ago
Promotion (must include link to source code) Inkrail: Offline, Minimal, Built for Deep work
Inkrail is a quiet, native writing desk for Mac — built for focused, distraction-free writing with a calm, paper-inspired interface.
Write offline. No accounts. No subscriptions. Just a clean place to think, draft, and create.
Features:
• Native Mac experience
• Offline-first writing workflow
• Minimal, distraction-free interface
• Paper-inspired desk aesthetic
• Built for calm, focused writing sessions
• Open source and privacy-friendly
Inkrail is designed for writers, note-takers, and creatives who want a simpler, more intentional place to work.
GitHub: https://github.com/Aaryanverma/inkrail
Open source project for people who value thoughtful tools over noisy software.
r/SwiftUI • u/lanserxt • 1d ago
Tutorial iOS 27.1: ReservedRegion
r/SwiftUI • u/jihwan0102 • 3d ago
Promotion (must include link to source code) SwiftUI previews on a real iPhone, built on Linux (no Mac)
I built peek (open source, my project) because I don't have a Mac but wanted to iterate on SwiftUI without rebuilding and sideloading an IPA after every change.
You run "peek dev MyApp/" on Linux and save a file; about a second later the view on your iPhone updates. It's the real SwiftUI on a real device, so animations, gestures and the iOS 26 tab bar behave like they do in your app. It handles Preview blocks, UIKit views, or the whole app, with SwiftPM packages, macros and resources, and print() output shows up in the terminal.
It cross-compiles your code into a dylib with swiftc and xtool's iOS SDK, signs it with your free Apple ID certificate, and a small host app (SideStore, AltStore or LiveContainer) loads it.
https://github.com/kimikr/peek
Only tested on my own phone so far (iOS 27, in LiveContainer). Feedback welcome, especially from anyone running it outside LiveContainer.
r/SwiftUI • u/3011adi • 3d ago
Built a cozy dual-screen pizzeria game in SwiftUI where dragging across the foldable hinge slides pizzas into the oven and folding shuts the box
r/SwiftUI • u/Mindless_Diet8721 • 2d ago
i've been writing swiftui on windows and running it on my iphone, no mac
built it because i didn't want to buy a mac just to learn swiftui.
edit, hit run, it's on the phone in about 30 sec. you can control the phone from the pc too
still early, only tested on my iphone so far. would love people to try it and tell me what breaks its free + open source https://github.com/Dadon-11/SwiftWin-Studio
r/SwiftUI • u/Rahul-Kachhwah • 3d ago
Code Review A Folder Organizer: a 500 KB, zero-deletion file organizer for macOS in pure SwiftUI (Free & Open Source)
reddit.comr/SwiftUI • u/Every_Technology3291 • 4d ago
SwiftUIWeb: run SwiftUI-style Swift in the browser (Embedded Swift to WebAssembly). Demo with Apple's Food Truck on iPhone, iPad and web
Hi all. I've been building SwiftUIWeb, an open-source framework that lets you describe screens with SwiftUI's own names (View, State, Observable, NavigationStack, NavigationSplitView, List, Table, Charts, MapKit, ...) and run them in the browser. The app compiles with Embedded Swift to WebAssembly, runs in a Web Worker, and renders ordinary DOM laid out by CSS (not a canvas).
The video runs Apple's Food Truck sample three times: iPhone, iPad, then the web, from the same sources. The sample is Apple's code with a short list of adaptations, documented in the example's README (mainly Combine -> Observation, plus stand-ins for StoreKit, WeatherKit and passkeys that have no browser counterpart). The point of the exercise was to find what SwiftUI the framework was missing, so those gaps were closed in the framework.
Things I'd rather you hear from me:
- It's a preview; the API may still change before 1.0.
- The first download is large compared with JS frameworks (about 400 KB Brotli for a counter, ~930 KB for the component playground). In my React comparison a small board app transfers 552 KB against React's 57 KB; interactions after load are on par. Smaller output is the top roadmap item.
- No Combine, UIKit or AppKit; no SwiftData, WidgetKit, App Intents, CloudKit, Metal.
- Needs the swift.org Swift 6.4 toolchain and its WebAssembly SDK (Xcode's compiler doesn't build wasm).
Repo (MPL-2.0): https://github.com/Vitorsilveira31/SwiftUIWeb Food Truck example: https://github.com/Vitorsilveira31/SwiftUIWeb/blob/main/Examples/FoodTruck/README.md
I'd love feedback, especially on SwiftUI APIs that behave differently from Apple's.
r/SwiftUI • u/TemporaryBuyer3806 • 4d ago
SwiftUI + Metal: a draggable holographic globe with orbiting text
I built this onboarding interaction in SwiftUI. The globe rotates under a ring of lettering, reacts to a press or drag, and zooms through the screen when you tap the button.
Here's how the SwiftUI version works:
- A TimelineView with the animation schedule asks a motion driver for the current frame. The driver supplies rotation, zoom, the text-ring angle and touch effects, so the renderer and the surrounding SwiftUI controls use the same frame state.
- The globe is a Metal shader applied with SwiftUI's .colorEffect to a Rectangle. ShaderLibrary passes in the view size, globe centre, radius and motion parameters. The land and lettering are sampled from two signed distance field textures: a 2048 x 1024 land map and a 4096 x 256 text strip.
- DragGesture(minimumDistance: 0) handles touch-down, movement and release. A press slows the rotation and zooms the globe in. Dragging turns it; release velocity feeds the fling. A tap starts a ripple, while a held press reveals the night lighting and connection arcs.
- The zoom uses a damped spring in the motion driver. The SwiftUI button has its own pressed scale and spring, then triggers the globe's zoom transition.
- accessibilityReduceMotion pauses the animated TimelineView. The globe stays still, the button's moving gradient stops, and a press switches to the night state immediately.
The land data comes from Natural Earth. This is an implementation study based on an onboarding reference; I don't have the original designer's credit.
r/SwiftUI • u/UsukIsBad • 4d ago
Tutorial MenuBarExtra(isInserted:) kept undoing my @AppStorage write. The stack trace showed SwiftUI writing the stale value back
Edit: the first version of this post bound $app.showIcon straight to the @Published property, which caused an endless redraw loop (about 97% CPU). The code below is corrected; details at the end of the fix section. Sorry if you copied the earlier version.
My menu bar app has a "Show in menu bar" toggle, and opening the app again from Finder is supposed to bring a hidden icon back. The usual pattern: MenuBarExtra(isInserted:) bound to @AppStorage, and the app delegate flips the stored value on reopen.
// App
@AppStorage("showIcon") private var showIcon = true
MenuBarExtra(isInserted: $showIcon) { ... }
// AppDelegate
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows: Bool) -> Bool {
UserDefaults.standard.set(true, forKey: "showIcon")
...
}
It passed my tests, because I always started with the icon visible and hid it from Settings. It failed when the app launched with the icon already hidden: the handler ran (I logged it), the value went to true, and it was false again before defaults read polling every 100 ms could see it. Deferring the write by 0.3 s didn't help. Weirder: a defaults write from Terminal while the app was running did stick.
So I added a KVO observer on the key and logged Thread.callStackSymbols on every change. The false was written by SwiftUI itself:
-[NSUserDefaults setObject:forKey:] // showIcon = false
UserDefaultLocation.set(_:transaction:)
Binding.wrappedValue.setter
MenuBarExtraController.observeValue(forKeyPath:of:change:context:)
NSKeyValueDidChange
_NSSetBoolValueAndNotify
MenuBarExtraController.updateConfiguration(_:environment:)
AppMenuBarExtrasController.updateMenuBarExtras(namespace:sceneList:)
AppDelegate.appGraphDidChange() // SwiftUI's, not mine
GraphHost.flushTransactions()
During a normal graph update, MenuBarExtraController sets a Bool on its status item, its own KVO observer fires, and it writes the item's state back through the isInserted binding. The scene still had the old value at that point, so what went back was false. That last part is my reading (I can't see SwiftUI's source), but the stack is clear about who wrote it.
The fix was to stop having two writers. The flag is now one @Published property that the scene observes, and reopen, the Settings toggle and Restore Defaults all go through it:
final class Controller: ObservableObject {
static let shared = Controller()
@Published var showIcon: Bool {
didSet { UserDefaults.standard.set(showIcon, forKey: "showIcon") }
}
...
}
@main
struct ScrollrApp: App {
@NSApplicationDelegateAdaptor private var delegate: AppDelegate
@ObservedObject private var app = Controller.shared
var body: some Scene {
// MenuBarExtra writes isInserted back on every update, so skip equal writes
MenuBarExtra(isInserted: Binding(
get: { app.showIcon },
set: { if $0 != app.showIcon { app.showIcon = $0 } }
)) { ... } label: { ... }
Settings { ... }
}
}
// AppDelegate
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows: Bool) -> Bool {
app.showIcon = true
...
}
Now the scene gets true in the same update that inserts the item, and the value sticks.
The equality check in the binding matters. My first version bound $app.showIcon directly, and Scrollr sat at about 97% CPU while idle: MenuBarExtra writes isInserted back on every update, @Published announces a change even when the value is the same, the scene updates again, and so on forever. A CPU sample showed exactly that cycle. Skipping equal writes breaks it (back to 0% idle).
Two smaller things from the same code:
OpenSettingsActiononly exists in the environment, so the delegate can't make one. The menu bar label captures it in.onAppearand hands it to the delegate, which calls it on the next run loop turn after showing the icon.- AppKit also stores the status item's visibility in your app's defaults (
NSStatusItem VisibleCC Item-0on macOS 27). Deleting it didn't change this bug, but it's worth knowing when you're poking at menu bar state.
Tested on macOS 27.2 / Xcode 27.2. The app is Scrollr, a small open-source (MIT) utility that reverses mouse wheel scrolling but leaves the trackpad alone: https://github.com/atuuuuuuu/Scrollr (fix in commits 000fd62 and fd29bb8, files ScrollrApp.swift and Controller.swift).
Has anyone else run into MenuBarExtra writing its binding back like this? Curious whether there's a cleaner pattern than moving the state into an ObservableObject.
r/SwiftUI • u/Necessary_End6429 • 4d ago
Built a menu bar app in SwiftUI that turns trackpad edges and corners into controls
I have been building Rimline, a menu bar app for macOS where the edges and corners of the trackpad are programmable. The whole UI, including the settings and the on-screen HUD, is SwiftUI, with a thin layer underneath for reading raw touch positions.
Things that were harder than I expected:
- Telling a deliberate edge slide from a palm or a resting thumb. I ended up with a typing guard that ignores the pad while keys are being pressed.
- Hold a corner, slide toward a place on the screen, show an outline, and move the window on lift. The outline overlay was the fiddly part.
- Rules that switch layouts on their own (headphones connected, external display, frontmost app, time of day) and put everything back when the rule ends.
Universal build, macOS 13 and later. Happy to go into any of these if people are curious, and I would like feedback on the HUD design.
It is called Rimline, page at rimline.zawalid.com
Promotion (must include link to source code) Made an open-source menu bar for macOS in SwiftUI, a few things I learned along the way
Hey everyone 👋
My friend and I have been working on StableBar for a while now. It's a menu bar for macOS, a bit like SketchyBar or simple-bar, except you set it up in a Settings window instead of writing shell scripts. It's free and open source (MIT): https://github.com/Seb-GRAF/StableBar
Since this is r/SwiftUI, I thought I'd share a few things we ran into while building it, in case it helps someone:
The bar is a SwiftUI view inside an NSPanel. Each display gets its own borderless, non-activating panel with an NSHostingView. The border lives in a second panel that ignores clicks, so it never gets in the way of the widgets.
Popups morph into each other. Every popup is its own panel too. When you move from one widget's popup to the next, a temporary panel carries the background across while the two contents cross-fade.
Watch out for view identity with .glassEffect**.** On macOS 26 the bar can use Liquid Glass. If your background flips between an if and an else when a color changes on hover, SwiftUI rebuilds everything inside it. For us that tore down the popup's anchor and closed the popup. Keeping one view structure and switching the glass to .identity fixed it.
The app takes its own screenshots. All the images in the README are drawn offscreen by the app from small "scene" files with sample data, so nothing real runs. CI uses the same thing to post before/after images on every pull request, which makes reviewing UI changes so much easier.
It works with AeroSpace, yabai, OmniWM and Rift, and you can drag widgets around right on the bar. macOS 14+ on Apple silicon.
Happy to answer questions or dig into any of this, and feedback is very welcome!
r/SwiftUI • u/sirily1997 • 5d ago
We built MotionSwift: an open-source native SwiftUI view to render Remotion clips with a built-in timeline editor
Hey everyone,
We just open-sourced MotionSwift, something we put together to get native rendering performance without relying on Remotion and headless Chrome.

We've been using it in our day-to-day video production pipeline, and so far we're seeing roughly 10–20x faster renders while using only about 10% of the memory compared to the Remotion + Chrome setup. We also brought a visual editor and timeline preview directly into Swift, so you can inspect and adjust agent-generated compositions natively on both iOS and macOS.
The eventual goal is 100% compatibility with Remotion, but we're still working our way there. There's still plenty of room to improve the APIs, rendering speed, and overall platform support.
Here's the repo if you want to check it out:
https://github.com/rxtech-lab/MotionSwift
Along with the rendering engine, we also put together a timeline view, property editor, and SwiftUI preview so you can inspect and adjust compositions natively on macOS, iOS, and iPadOS.
r/SwiftUI • u/PublitApp • 5d ago
Question Replacing TimelineView with one shared @Observable clock in my transit app (open source)
I'm building Publit, an open-source public transport app for iPhone and Apple Watch, written in SwiftUI. Almost every row shows a countdown like "in 4 min", so most of the UI depends on the current time.
The first version used `TimelineView(.periodic(from:by:))` on the departure and trip screens. Freeze logs from an early build showed the main thread stuck inside SwiftUI's update loop, in `requestUpdate(after:)`, while it drew the trip screen.
I replaced the timelines with a plain observable clock that ticks on whole-minute boundaries. One timer serves every row in a list, and thanks to Observation only the views that read `now` redraw on a tick:
```swift
final class Ticker {
static let minute = Ticker(every: 60)
private(set) var now = Date()
u/ObservationIgnored let interval: TimeInterval
u/ObservationIgnored private var loop: Task<Void, Never>?
init(every interval: TimeInterval) {
self.interval = interval
loop = Task { [weak self] in
while !Task.isCancelled {
guard let delay = self?.delayToNextTick() else { return }
try? await Task.sleep(for: .seconds(delay))
guard let self, !Task.isCancelled else { return }
self.now = Date()
}
}
}
private func delayToNextTick() -> TimeInterval {
Ticker.delay(toNextMultipleOf: interval, from: Date())
}
nonisolated static func delay(toNextMultipleOf interval: TimeInterval, from date: Date) -> TimeInterval {
let t = date.timeIntervalSinceReferenceDate
let next = (floor(t / interval) + 1) * interval
return max(0.05, next - t + 0.05)
}
}
```
For a small part of a screen that needs its own pace, a wrapper runs the same loop in `.task`, so it stops when the view leaves the screen:
```swift
Clocked(every: 30) { now in
LeaveHero(itinerary: itinerary, now: now, framed: false)
}
```
Two details mattered. The delay goes to the next whole multiple of the interval plus 50 ms, so the minute has really changed when views redraw. And the loop only holds `self` weakly, so a clock that nobody uses can go away.
Full file: https://github.com/elija-7580/Publit/blob/main/Sources/Views/Components/Ticker.swift
Repo (AGPL-3.0): https://github.com/elija-7580/Publit
Has anyone else hit this with TimelineView? I'd like to know whether I was using it wrong or whether a shared clock is the usual fix for long lists of countdowns.
Full disclosure: I build Publit with help from AI coding tools. I review, test and maintain it myself.Replacing TimelineView with one shared u/Observable clock in my transit app (open source)
r/SwiftUI • u/IllBreadfruit3087 • 5d ago
News The iOS Weekly Brief: Issue #86. Swift Student Challenge 2027, New iOS releases, testing with agents, SwiftUI architectures, fixedSize(), GlassEffectContainer, animating SF Symbols, SwiftUI inspector, Effect Systems vs DI, and Bruno
r/SwiftUI • u/myeleventhreddit • 5d ago
One virtual ACP agent in Xcode v27+ streams any model to Agent Mode (ProxyPilot)
XCUI practitioners rejoice
r/SwiftUI • u/UsukIsBad • 5d ago
Promotion (must include link to source code) Drawing a radial menu in SwiftUI: wedges with constant-width gaps and one shared shadow (open-source Mac app)
I built Convrt, an open-source macOS menu bar app: hold Shift while dragging files and a radial wheel opens at the cursor to convert them. The windowing is AppKit (a borderless, non-activating NSPanel), but the wheel itself is SwiftUI in an NSHostingView, and two drawing problems took me a while, so sharing in case it helps someone.
1. Gaps between wedges that stay the same width. If you just shrink each wedge's angle, the gap is wide at the outer edge and pinches to nothing at the inner edge. Instead, each edge is pulled in by an angle that depends on its radius, asin(halfGap / radius), so the gap is a constant number of points everywhere:
struct WheelWedge: Shape {
let index: Int, count: Int
let innerRadius: CGFloat, outerRadius: CGFloat
var gap: CGFloat = 5
var corner: CGFloat = 3 // stroke with 2 * corner for rounded corners
func path(in rect: CGRect) -> Path {
let c = CGPoint(x: rect.midX, y: rect.midY)
let slice = 2 * Double.pi / Double(max(count, 1))
let mid = -Double.pi / 2 + Double(index) * slice // slice 0 at the top
let a0 = mid - slice / 2, a1 = mid + slice / 2
let rOut = outerRadius - corner, rIn = innerRadius + corner
let half = Double(gap / 2 + corner)
let dOut = asin(min(half / Double(rOut), 1))
let dIn = asin(min(half / Double(rIn), 1))
var p = Path()
p.addArc(center: c, radius: rOut, startAngle: .radians(a0 + dOut), endAngle: .radians(a1 - dOut), clockwise: false)
p.addArc(center: c, radius: rIn, startAngle: .radians(a1 - dIn), endAngle: .radians(a0 + dIn), clockwise: true)
p.closeSubpath()
return p
}
}
The rounded corners come from insetting the radii by corner and stroking the shape with a line width of 2 * corner in the same color.
2. One soft shadow for the whole ring. A .shadow on each wedge made the shadows overlap and look muddy. Putting all wedges in a ZStack, then .compositingGroup() before .shadow(...), renders them as one layer with a single shadow. Labels are positioned in a separate ForEach on top with .allowsHitTesting(false), so they never get the shadow.
Hit testing doesn't use SwiftUI at all: which wedge is under the cursor is a pure function (atan2 plus distance from the centre), which made it easy to unit-test and to drive the highlight from scroll, Tab and arrow keys.
Source (MIT): https://github.com/atuuuuuuu/Convrt (the wheel is in Convrt/UI/RadialWheelView.swift). Caveats if you want to try the app: the current release is Apple silicon only and not notarized yet, so first launch is right-click → Open.
Happy to take code review, especially on the shape math.
r/SwiftUI • u/mindspaceFounder • 5d ago
Shipped an app with fifteen distinct document types and learned that two
Shipped an app with fifteen distinct document types and learned that two .sheets on one view don't stack
Not a promo post — the specific SwiftUI lessons, from a first app that's now live.
Two .sheet modifiers on the same view compete, they don't queue. My Guided tab froze dead on a specific path and I spent a day on the entitlement logic before realising a second sheet modifier was the whole problem. Fix was one enum GuidedSheet: Identifiable with a case per destination and a single .sheet(item:) switching on it. That pattern has since replaced every multi-sheet view I had.
Raising a sheet from another sheet's onDismiss wedges presentation entirely. Related, worse, harder to spot.
onGeometryChange fires during a sheet's presentation transform. I was caching card frames with .frame(in: .global). When the paywall animated up, the presenting view got scaled, every cached frame updated to garbage, and you could see the cards twitch. Fixed by guarding the write while a sheet is showing — the geometry during a presentation is never the geometry you want.
onChange can't observe a computed read from a store. Obvious in hindsight. Cost me an hour.
App's in my profile if anyone's curious, but I'm here for the code. Anyone found a cleaner multi-sheet pattern than the Identifiable enum?