Search results for

swiftui

16,626 results found

Post

Replies

Boosts

Views

Activity

SF symbols not rendering in swiftui views
Summary: The minus.capsule and minus.capsule.fill SF Symbols do not render in my project. Other SF Symbols (e.g., plus.capsule and minus.circle) render correctly in the same context. Steps to Reproduce 1. Add an Image(systemName: minus.capsule) or Image(systemName: minus.capsule.fill) to a SwiftUI view. 2. Run the app on the latest macOS. Expected Result The minus capsule symbols should render consistently, similar to plus.capsule. Actual Result minus.capsule and minus.capsule.fill do not render at all. Additional Testing • Replaced minus.capsule with minus.circle: renders correctly. • Swapped the right-hand plus.capsule symbol in my slider with minus.capsule: the symbol fails to render in that position as well. That rules out clipping or layout issues.
2
0
135
Oct ’25
Reply to Shared modelContainer between DocumentGroup and WindowGroup
I'm also looking for a way to do this. I assume that it's not possible with the currently released version of SwiftData/SwiftUI, and that you'd need to drop back to manually sharing a model container somehow, or present the content that should have been in a separate window in a sheet, meaning you can't present more than one at a time. It's quite limiting.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to .disabled() doesn't VISUALLY disable buttons inside ToolbarItem on iOS 26 devices
It looks like it does have to do with how the button's label is declared. Here's my post about another bug where a button's hit target shrinks based on its label declaration: SwiftUI Button with Image view label has smaller hit target So if I change this sample code to use a label: closure with a Label() view, the button does appear gray when disabled. Interestingly though, it still responds to taps with a bounce animation, even though the action isn’t triggered. That’s still inconsistent with how disabled buttons behave outside of a toolbar. Also, the button grows slightly wider when disabled. Code var body: some View { NavigationStack { VStack { Button{ print(Body button tapped) } label: { Label(Body Button, systemImage: checkmark) } .labelStyle(.titleOnly) .buttonStyle(.borderedProminent) .disabled(isButtonDisabled) Toggle(Disable buttons, isOn: $isButtonDisabled) Spacer() } .padding() .navigationTitle(Device: (osTitle)) .navigationBarTitleDisplayMode(.large) .toolbar { ToolbarItem { Button { prin
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
SwiftData ModelActor causes 5-10 second UI freeze when opening sheet
I'm experiencing a significant UI freeze in my SwiftUI app that uses SwiftData with CloudKit sync. When users tap a button to present a sheet for the first time after app launch, the entire UI becomes unresponsive for 5-10 seconds. Subsequent sheet presentations work fine. App Architecture Service layer: An @Observable class marked with @MainActor that orchestrates operations Persistence layer: A @ModelActor class that handles SwiftData operations SwiftUI views: Using @Environment to access the service layer The structure looks like this: @Observable @MainActor final class MyServices { let persistence: DataPersistence init(modelContainer: ModelContainer) { self.persistence = DataPersistence(modelContainer: modelContainer) } func addItem(title: String) async { // Creates and saves an item through persistence layer } } @ModelActor actor DataPersistence { func saveItem(_ item: Item) async { // Save to SwiftData } } The app initializes the ModelContainer at the Scene level and passes it through
2
0
125
Oct ’25
Reply to Fous, FocusState and Architecture
I’ve run into a similar issue in a macOS app and ended up rethinking how to use SwiftUI’s focus system. The app has the usual triple-panel layout: sidebar, content, inspector. The content is two tables, either of which can be focused. Each table has a TableController, exposed via .focused(). The inspector reads the focused controller to update its display, and the sidebar shows its selection—both via @FocusedValue. On paper this works, but there’s a catch: when the sidebar or inspector itself gains focus (e.g. a text field), the focused table controller becomes nil. I tried various .focus modifiers but could never get the behaviour I wanted. What I really needed was a property influenced by focus but not identical to it. For example: Use the focused table controller if one exists. Otherwise fall back to the last focused table controller. Add other rules as needed. The solution was to introduce an active table controller managed by an @Observable object in the environment. The sidebar and inspector ob
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to View with FetchRequest does not always update when data changes
ForEach(items) uses the item identifier to identify the destination view. When you change the item name, the item identifier doesn't change, and so SwiftUI doesn't guarantee to update the destination view, which explains why the destination view doesn't show the latest change. You can fix the issue by converting the destination view to a separate custom view, and in the custom view, annotate the item with @ObservedObject which tells SwiftUI to observe the properties of the item (and update the view for any property change), as shown below: struct EditView: View { @ObservedObject var item: Item var body: some View { VStack { Text(Item (item.name ?? unnamed) at (item.timestamp!, formatter: itemFormatter)) Button(Add '?') { item.name = (item.name ?? ) + ? try? PersistenceController.shared.container.viewContext.save() } } } } struct ContentView: View { ... NavigationLink { EditView(item: item) } label: { ... } Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to How to handle required @relationship optionals in SwiftData CloudKit?
Sorry for not being clear. As an example, assuming you have some SwiftUI views that render the relationship, and the views accept only an non-optional array, it will make sense that your SwiftData model creates a computed property to wrap relationship. Here, the Swift views are the other part of your app that prefers to consume a non-optional array. I hope this makes the point clear. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Oct ’25
Reply to Potential Structural Swift Concurrency Issue: unsafeForcedSync called from Swift Concurrent context
[quote='860800022, reglot, /thread/802423?answerId=860800022#860800022, /profile/reglot'] this fires when AVSpeechSynthesisVoice is initialized inside of an asynchronous context. [/quote] Yeah, that’s the sort of thing I saw expecting. And with that hint I was able to reproduce this trivially: Using Xcode 26.0 on macOS 26.0, create a new project from the macOS > App template, choosing SwiftUI as the UI. Add this code to the VStack in ContentView.swift: Button(Test) { Task { let voice = AVSpeechSynthesisVoice(language: nil) print(voice) } } Choose Product > Run. Click the Test button. I’m not sure whether I’d consider that a bug or not, but it definitely warrants deeper consideration from the engineering team responsible for that code. Please file a bug about this, making sure to include a reference to this forums thread and also attach a sysdiagnose log taken shortly after reproducing the issue. I’d appreciate you posting your bug number, just for the record. Share and Enjoy — Quinn “The Eskimo
Oct ’25
SwiftUI View Stops Updating When Using @Environment - Xcode 26
Hi all - i'm encountering a strange issue since updating to Xcode 26.0.1. It seems that any SwiftUI Views that have an :ObservedObject property that contains @Published properties, and use those properties inside the View, no longer update when those properties are updated when the view also has an @Environment property. If I remove the @Environment property and any usage of it, the view updates correctly. The specific environment property i'm using is .safeAreaInsets, like so: @Environment(.safeAreaInsets) private var safeAreaInsets Is this a recognised bug in the latest iOS 26 SDK? Thanks
2
0
141
Oct ’25
Reply to SwiftUI Controls Documentation
OK, after quite a bit more searching, I came across several links. One of the links was Gosh Darn SwiftUI - Cheat Sheet, which the link can not be displayed here Fabula For SwiftUI Human Interface Guidelines Interactful Another link, hackingwithswift quick-start/swiftui which can not be displayed. I still have not found a guide that shows controls graphics and their usage. Jim
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
SwiftUI Controls Documentation
Hi, I am looking for comprehensive controls documentation for SwiftUI. When searching on the Apple site, I have not seen any documentation that shows a picture of a control and an explantation of what it does, for all the available controls. I have also searched the web for such documentation, and have not found any. When I was learning Rust, I came across a beautiful document about GTK3 (PDF) that had a complete list of controls, including pictures. If something looked interesting I could do a search for more details. Thanks, Jim
1
0
166
Oct ’25
Issue with StoreKit 2 Purchases: "unfinalized statements / unfinished backups" SQLite Crash
Hi, I’m running into a persistent error while implementing StoreKit 2 renewable subscriptions in my SwiftUI app. Context I have a two-screen flow: Screen 1: user selects a subscription plan (monthly / yearly). Screen 2: user fills out personal information and taps Subscribe that triggers the purchase function. On first launch or the first couple of purchases (on both Storekit's local and Sandbox testing), everything works fine. The App Store popup appears, the purchase goes through, and I get the transaction result. But after a few runs (3rd or 4th purchase attempt onward), my app crashes the moment the App Store purchase popup appears. Error Logs When the crash happens, the console shows: `unable to close due to unfinalized statements or unfinished backups BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /private/var/mobile/Containers/Data/Application/D8D97A11-DF06-4EF2-AC55-138C4739A167/Library/d6d2e85a60f0480c4c17834eeb827a14_MPDB.sql
1
0
129
Oct ’25
Reply to [iOS 26] Can no longer detect whether iPhone has notch
Depending on your minimum deployment version, isn't it just the matter of a elimination game with UIDevice.current.name? import SwiftUI struct ContentView: View { var body: some View { VStack { ... } .onAppear(perform: { let device = UIDevice.current print(1 (device.name)) // iPhone 16 Pro print(2 (device.systemName)) // iOS print(3 (device.model)) // iPhone print(4 (NSUserName())) // mobile print(5 (device.description)) // //print(6 (device.model)) // iPhone }) .padding() } }
Topic: UI Frameworks SubTopic: General Tags:
Oct ’25
Image Miniaturization Issue
I have three toolbar buttons with images from Assets.xcassets. Initially, I didn't use @1x, @2x, @3x sizes. I just put one size (72 x 72) for all of them. It was never a problem till a few days ago. The reviewer has reported numerous issues, which all seem to originate from miniaturized toolbar images. They have given me a screenshot from an iPad. Now, each of the three to the left has shrunken to 4 x 4, according to them. Some lines of code are the following. import SwiftUI struct ContentView: View { var body: some View { NavigationStack { ZStack { VStack { ... ... ... } .background(.brown) .navigationBarTitleDisplayMode(.inline) .navigationBarItems( leading: HStack(content: { Button { } label: { Image(ToolbarImage1) .resizable() .foregroundColor(.red) .aspectRatio(contentMode: .fit) .frame(width: 28) } Button { } label: { Image(ToolbarImage2) .resizable() .foregroundColor(.cyan) .aspectRatio(contentMode: .fit) .frame(width: 28) } Button { } label: { Image(ToolbarImage3) .resizable() .foregroundColo
Topic: UI Frameworks SubTopic: SwiftUI
3
0
120
Oct ’25