Search results for

swiftui

16,584 results found

Post

Replies

Boosts

Views

Activity

Missing Context menu items in Xcode 26 on a fresh project
When following the official SwiftUI Tutorial Landmarks, I should be able to Cmd-Ctrl-Click an element of a preview in Selectable mode to view a list of options. But Xcode shows only one option (Embed). Furthermore, if I try to type anything the popover breaks completely and grows in length infinitely. I am not sure whether this is a bug, or I missed something when installing Xcode, or both
2
0
220
Nov ’25
Reply to Crash when trying to use instruments memory debugging
Start by adding an exception breakpoint in Xcode. An exception breakpoint will pause your app at the point of the crash so you can see where the crash occurs in your code. In Xcode choose Debug > Breakpoints > Creation Exception Breakpoint to set an exception breakpoint. For anyone to provide further help, you have to provide more information. Some helpful information to provide includes the following: When does your app crash, at startup or when something else happens in your app? Is this an iOS or Mac app? Does your app use SwiftUI, UIKit, AppKit, or some other framework? What version of Xcode are you running? Is your app a document app or a regular app? Did you add any code recently that could cause the crash? Or did the app start crashing without you making any code changes? If the exception breakpoint points at code you wrote, provide that code. The stack trace you included doesn't have enough information for anyone to help. People here are going to need to see code to help you.
Nov ’25
Reply to Switfui: change color in 'menu'
As far as I know you cannot change the styling for a menu item because the menu is displayed appropriately for the operating system it's running on. So, trying .foregroundColor(), .foregroundStyle(), .tint() etc. likely won't work. The only way you can make a menu item red is by giving the Button the destructive role. This, by default, makes the item red, but it may also have other side effects that you may not want: Button(role: .destructive) From the documentation: Use this role for a button that deletes user data, or performs an irreversible operation. A destructive button signals by its appearance that the user should carefully consider whether to tap or click the button. For example, SwiftUI presents a destructive button that you add with the swipeActions(edge:allowsFullSwipe:content:) modifier using a red background. So please, use it wisely. In the meantime, why not raise a feedback request, and ask for a way to tint a menu item? https://feedbackassistant.apple.com/
Topic: UI Frameworks SubTopic: SwiftUI
Nov ’25
.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
201
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
226
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
297
Nov ’25