Search results for

swiftui

16,607 results found

Post

Replies

Boosts

Views

Activity

.contactAccessPicker shows blank sheet on iOS 26.1
I’m running into an issue using .contactAccessPicker on a device running iOS 26.1 - a blank sheet appears instead of the expected Contact Access Picker. It works on: Simulator (iOS 26.0) Device + Simulator (iOS 18.6) The issue appears specific to real devices on iOS 26.0+. Environment: Device: iPhone 16 Pro iOS Versions Tested: 26.0 and 26.1 Xcode 26.0.1 SwiftUI app, deployment target: iOS 17+ @available(iOS 18.0, *) private var contactPicker: some View { contactsSettingsButton(Title) { showContactPicker = true } .contactAccessPicker(isPresented: $showContactPicker) { _ in Task { await contactManager.fetchContacts() showSelectContacts = true } } } Filed a Feedback: FB20929400 Is there a known workaround?
6
0
206
Nov ’25
Correct SwiftData Concurrency Logic for UI and Extensions
Hi everyone, I'm looking for the correct architectural guidance for my SwiftData implementation. In my Swift project, I have dedicated async functions for adding, editing, and deleting each of my four models. I created these functions specifically to run certain logic whenever these operations occur. Since these functions are asynchronous, I call them from the UI (e.g., from a button press) by wrapping them in a Task. I've gone through three different approaches and am now stuck. Approach 1: @MainActor Functions Initially, my functions were marked with @MainActor and worked on the main ModelContext. This worked perfectly until I added support for App Intents and Widgets, which caused the app to crash with data race errors. Approach 2: Passing ModelContext as a Parameter To solve the crashes, I decided to have each function receive a ModelContext as a parameter. My SwiftUI views passed the main context (which they get from @Environment(.modelContext)), while the App Intents and Widgets created and pas
5
0
232
Nov ’25
Reply to Correct SwiftData Concurrency Logic for UI and Extensions
Assuming the task (Task) is triggered from a SwiftUI button action, adding @MainActor won't change anything because SwiftUI View is now MainActor-ed. With or without specifying @MainActor, the task will start from the main actor, do deleteEvent in the database manager actor, and come back to the main actor to run dismiss. Regarding the delay, do you have a minimal project that reproduces the issue? If yes, I'd be interested in taking a look. I am wondering if deleteEvent calls other async methods, which eventually leads to dismiss being called before the deletion is done. Without looking into a reproducible case, however, I can't say anything for sure. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Nov ’25
Reply to CryptoTokenKit: TKSmartCardSlotManager.default is nil on macOS (Designed for iPad) but works on iPadOS and macOS
That’s annoying, but not super surprising. There are subtle differences in how smartcards are supported on iOS and macOS, and this support was added before iOS Apps on Mac was a thing, so it’s easy to see how this might work for native apps but fail for an iOS app running on the Mac. Still, it’s reasonable to expect that this should work out of the box — I mean, that’s the whole reason the iOS Apps on Mac feature exists — and so it’d make sense for you to file a bug about this. Please post your bug number, just for the record. [quote='806426021, 0x3ff, /thread/806426, /profile/0x3ff'] is Mac Catalyst the correct/only path on macOS [/quote] That depends on whether your app is wedded to UIKit or not. The example you posted used SwiftUI, and if your app also uses SwiftUI then you have two choices: Use Mac Catalyst, resulting in SwiftUI on top of UIKit on Mac. Create a multi-platform SwiftUI app, resulting in SwiftUI on top of AppKit on Mac. Personally, I think the lat
Topic: App & System Services SubTopic: Hardware Tags:
Nov ’25
Reply to VZVirtualMachineView in SwiftUI App
[quote='806398021, Feu-Feu, /thread/806398, /profile/Feu-Feu'] I think I am fighting against proper SwiftUI lifecycle [/quote] Very likely. [quote='806398021, Feu-Feu, /thread/806398, /profile/Feu-Feu'] there is probably a solution making a NSViewControllerReporesentable [/quote] That’s definitely the path you should explore. [quote='806398021, Feu-Feu, /thread/806398, /profile/Feu-Feu'] rather than a VZVirtualMachineViewRepresentable. [/quote] I’m not sure what VZVirtualMachineViewRepresentable is. It has the VZ prefix, suggesting that it’s from the Virtualization framework, but it’s not actually a class in that framework. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’25
Reply to UIRequiresFullScreen Deprecation
So basically the fix is to: Make your app to support all orientations and support resizing. Easy ! All disable all orientations on iPad and stick to one orientation. The funny thing is that my app is already supporting all orientations and I'm using native SwiftUI but the problem is that the window controls are overlapping navigation of my app, which is using standard top-left navigation to go back. So my app is not usable on windowed mode. I've put a lot of effort on the landscape mode and I will need to disable it. Thank you.
Topic: UI Frameworks SubTopic: UIKit Tags:
Nov ’25
ARView ignores multi-touch events
Hi, How to enable multitouch on ARView? Touch functions (touchesBegan, touchesMoved, ...) seem to only handle one touch at a time. In order to handle multiple touches at a time with ARView, I have to either: Use SwiftUI .simultaneousGesture on top of an ARView representable Position a UIView on top of ARView to capture touches and do hit testing by passing a reference to ARView Expected behavior: ARView should capture all touches via touchesBegan/Moved/Ended/Cancelled. Here is what I tried, on iOS 26.1 and macOS 26.1: ARView Multitouch The setup below is a minimal ARView presented by SwiftUI, with touch events handled inside ARView. Multitouch doesn't work with this setup. Note that multitouch wouldn't work either if the ARView is presented with a UIViewController instead of SwiftUI. import RealityKit import SwiftUI struct ARViewMultiTouchView: View { var body: some View { ZStack { ARViewMultiTouchRepresentable() .ignoresSafeArea() } } } #Preview { ARViewMultiTouchView() }
1
0
303
Nov ’25
Reply to Scrolling through long lists with ScrollView and LazyVstack
They could be various things going on here depending on your implementation. So the first thing here is to profile your view to identify what coudl be causing the performance issues. Please review Optimize SwiftUI performance with Instruments. Another thing to consider is if you want to load all your data into memory including comments or fetch those as needed. That said, stack views load their child views all at once which makes layout fast and reliable, because the system knows the size and shape of every subview as it loads them while Lazy stacks trade some degree of layout correctness for performance, because the system only calculates the geometry for subviews as they become visible.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’25
Reply to EXC_BAD_ACCESS (code=EXC_I386_GPFLT) when using RegisterEventHotKey + SwiftUI AppDelegate
Any advice on a modern alternative (e.g., using NSEvent.addGlobalMonitorForEvents or another framework) that can replace this global hotkey mechanism would also be appreciated. In a SwiftUI View, to observe and react to keyboard input in a focused view hierarchy you can use the onKeyPress(_:action:) modifier. The would allow you specify key event matching conditions and provides an action to fire when a match is found. If you're using AppKits NSEvent.addGlobalMonitorForEvents you could use an observable object and SwiftUI would know when theirs an event change. For example: @Observable class Manager { var eventModifiers = EventModifiers() var localEventMonitor: Any? var globalEventMonitor: Any? init() { localEventMonitor = NSEvent.addLocalMonitorForEvents( matching: [.flagsChanged], handler: { [weak self] event in self?.eventModifiers = self?.convertModifierFlags(event.modifierFlags) ?? EventModifiers() return event } ) globalEventMonitor = NSEvent.addGlobalMonitorForEvents( matching: [.flag
Topic: UI Frameworks SubTopic: SwiftUI
Nov ’25
EXC_BAD_ACCESS (code=EXC_I386_GPFLT) when using RegisterEventHotKey + SwiftUI AppDelegate
Hi everyone, I’m working on a macOS SwiftUI app that integrates a global keyboard shortcut using the old Carbon API (RegisterEventHotKey, InstallEventHandler, etc.). Everything works fine initially, but I’m running into a consistent EXC_BAD_ACCESS (code=EXC_I386_GPFLT) crash when the app is reopened, or sometimes even while drawing on my SwiftUI canvas view. Setup Here’s the relevant setup (simplified): private let hotKeySignature: FourCharCode = 0x626c6e6b // 'blnk' private weak var hotKeyDelegate: AppDelegate? private func overlayHotKeyHandler( _ callRef: EventHandlerCallRef?, _ event: EventRef?, _ userData: UnsafeMutableRawPointer? ) -> OSStatus { guard let appDelegate = hotKeyDelegate else { return noErr } return appDelegate.handleHotKey(event: event) } final class AppDelegate: NSObject, NSApplicationDelegate { private var hotKeyRef: EventHotKeyRef? private var eventHandlerRef: EventHandlerRef? override init() { super.init() hotKeyDelegate = self } func applicationDidFinishLaunching(_
Topic: UI Frameworks SubTopic: SwiftUI
1
0
60
Nov ’25
Duplicate toolbar item and wrong document name in SwiftUI document based app
My app is a SwiftUI document based app using DocumentGroupLaunchScene. In iOS(iPadOS) 18.4, when it launches, it has duplicate toolbar items, and when I close the current document and open other documents, it adds more duplicates. It also shows a wrong document name, which shows the first opened document name. This issue can be reproduced in the sample code (Building a document-based app with SwiftUI). I have submitted Feedback (FB17025216), but not sure if this is a known bug or if I'm missing anything.
8
0
448
Nov ’25
iOS 26 regression: Slider does not respect step parameter
In iOS 26, the Slider control no longer respects the step parameter. For example, import SwiftUI struct ContentView: View { @State private var sliderValue: CGFloat = 16 var body: some View { Slider( value: $sliderValue, in: 0...100, step: 5, onEditingChanged: { editing in print(sliderValue) } ) } } In iOS 18, this prints values like 5, 35, 60, 95, etc. In iOS 26.0 (release version), this prints floats that are not rounded to the nearest 5, and the slider does not snap to values ending in 5. Feedback report number: FB20320542
Topic: UI Frameworks SubTopic: SwiftUI
6
0
317
Nov ’25