Search results for

swiftui

16,197 results found

Post

Replies

Boosts

Views

Activity

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:
6h
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:
8h
Canvas Is Not Updating in Xcode 26
I just updated to Tahoe 26 and Xcode 26, and now a SwiftUI project that was working just fine, simply shows a blank canvas. I closed Xcode and reopened, but get the same results. Note that there is no error message and the project builds and displays normally. Steps to blank canvas: Open Xcode I see Canvas Paused Click on the circle The Form opens with a blank screen Build the project The Form opens with all controls showing Jim
0
0
52
10h
watchOS app with @Published properties fails to compile in Xcode 26.0.1 - "missing import of defining module 'Combine'
I'm developing a watchOS companion app for my iOS app in Xcode 26.0.1 on macOS Sequoia. The watch app uses a simple ObservableObject class with @Published properties for state management, which compiles fine for iOS but fails for the watchOS target. Error: Initializer 'init(wrappedValue:)' is not available due to missing import of defining module 'Combine' Code: swiftimport SwiftUI import WatchConnectivity import Combine // Added explicitly class WatchConnectivityProvider: NSObject, ObservableObject { @Published var distance: Double = 0 @Published var isActive: Bool = false // Additional @Published properties... } Environment: Xcode 26.0.1 (17A400) macOS Sequoia watchOS deployment target: 11.0 Apple Watch Series 11 running watchOS 11.6.1 What I've tried: Adding import Combine explicitly Cleaning build folder Verifying target membership This same code pattern works in the iOS target Is @Published / Combine supported differently in watchOS under Xcode 26? This code worked in previous Xcode versions. Wh
0
0
28
11h
Fous, FocusState and Architecture
I am currently struggling with resolving what appear to be competing design issues, and (while I may be just demonstrating my own ignorance) I would like to share my thoughts in the hope that you may have useful insights. For purposes of discussion, consider a large and complex data entry screen with multiple sections for input. For all of the usual reasons (such as reuse, performance management, etc) each of these sections is implemented as its own, separately-compiled View. The screen is, then, composed of a sequence of reusable components. However, each of these components has internal structure and may contain multiple focusable elements (and internal use of .onKeyPress(.tab) {...} to navigate internally). And the logic of each component is such that it has an internal @FocusState variable defined with its own unique type. So, obviously what I want is on the one hand, to provide a tab-based navigation scheme for the screen as a whole, where focus moves smoothly from one component's internals to the next c
1
0
40
13h
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.
15h
AVPlayerViewController Mac Catalyst 26 Full Screen Crash
I have a SwiftUI Mac Catalyst app that shows a video player using a UIViewControllerRepresentable AVPlayerViewController. When I tap the full screen button on the native playback control, the app crashes. The app crashes only when built with Xcode 26. When I build with Xcode 16, this does not cause a crash. Here is some of the crash log: 0 CoreFoundation 0x000000019a5cc770 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000019a0aa418 objc_exception_throw + 88 2 CoreFoundation 0x000000019a69b7fc -[NSException initWithCoder:] + 0 3 AppKit 0x000000019eeee1d0 -[NSBezierPath(NSBezierPathDevicePrimitives) _deviceMoveToPoint:] + 104 4 AppKit 0x000000019eeec930 -[NSBezierPath appendBezierPathWithRoundedRect:xRadius:yRadius:] + 200 5 AppKit 0x000000019eeea238 +[NSBezierPath bezierPathWithRoundedRect:xRadius:yRadius:] + 88 6 AVKitMacHelper 0x0000000247d73cc4 -[AVScrubberSliderCell drawBarInside:flipped:] + 1264 7 AppKit 0x000000019f35cf7c -[NSSliderCell drawInteriorWithFrame:inView:] + 680 8 AppKit 0x000000
0
0
36
17h
Xcode Signing Fails: Provisioning Profile "doesn't match" com.apple.developer.driverkit.userclient-access entitlement
Hello everyone, I am migrating a legacy KEXT to a DriverKit (DEXT) architecture. While the DEXT itself is working correctly, I am completely blocked by a code signing issue when trying to establish the UserClient connection from our SwiftUI management app. Project Goal & Status: Our DEXT (com.accusys.Acxxx.driver) activates successfully (systemextensionsctl list confirms [activated enabled]). The core functionality is working (diskutil list shows the corresponding disk device node). The Core Problem: The userclient-access Signing Error To allow the app to connect to the DEXT, the com.apple.developer.driverkit.userclient-access entitlement is required in the app's .entitlements file. However, as soon as this entitlement is added, the build fails. Both automatic and manual signing fail with the same error: `Provisioning profile ... doesn't match the entitlements file's value for the ... userclient-access entitlement.` This build failure prevents the generation of an .app bundle, making it impossibl
0
0
12
21h
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
23h
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:
1d
Appearance of custom control changes depending on where it is used.
I made a custom SwiftUI control with two sliders trying to mimic the appearance of the new sliders in version 26 OSs. I was able to get something close to the way Apple's single slider looks and works. This is how it normally looks: And this is how it looks when one of the sliders is being dragged: This isn't perfect but I could live with it. Except that I want to use that control in a SwiftUI List, and by placing it in the list it doesn't have the same appearance though it functions the same. When the thumbs aren't being dragged it looks like this: Same as before which is great. But when one of the thumbs is being dragged it looks like this: Something about dropping the control into a List broke the transparency effect. All these screenshots were taken using the Xcode simulator for iOS. I achieved the transparency effect using .glassEffect(.clear.interactive(true)) on the thumb, along with a second capsule drawn on top when the thumb isn't being dragged. I needed the second capsule, if I me
Topic: UI Frameworks SubTopic: SwiftUI
0
0
66
1d
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
34
1d
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:
1d