Search results for

“swiftui”

17,492 results found

Post

Replies

Boosts

Views

Activity

Reply to AVPlayerView. Internal constraints conflicts
FWIW: After some experimentation, I've found that setting the AVPlayerView's controlsStyle property to .floating allows the view to load without getting the constraints errors. Of course that means you have to be able to use that style in your UI. And I don't see an equivalent way of making the same change using the AVPlayer in SwiftUI, so you have to use a NSViewRepresentable in a SwiftUI project.
Topic: Media Technologies SubTopic: Video Tags:
May ’26
tvOS SwiftUI - Siri "On-Screen Actions" breaks lazy lists
Hey team, This is a weird one, when Siri + On-Screen Actions are enabled in the Apple TV settings (General Settings), LazyVStack experiences severe main-thread hangs and very high CPU usage. The issue only occurs when Siri + On-Screen Actions are enabled in Apple TV device settings (General Settings). Disabling On-Screen Actions completely resolves the issue. The issue has been verified on multiple Apple TV devices, running tvOS 26.3, 26.4 and 26.5. The behavior was not observed in Simulators, only on an actual device. This seems to be caused by some type of accessibility overlap with SwiftUI. Running the below code with On-Screen Actions enabled in the Siri settings will demonstrate a complete hang of the CPU at 100% struct TestData { let id = UUID() var title: String } struct TestView: View { @State private var test: [TestData] = [] var body: some View { ScrollView { LazyVStack { ForEach(self.test, id: .id) { data in Button { } label: { Text(data.title) } } } } .task { var arr: [TestData] = [] for
0
0
483
May ’26
SF Symbols Variable Color — "Draw" symbols show no effect in Default mode
I've noticed an inconsistency between how the SF Symbols app and SwiftUI code handle variable color for symbols that use the Draw animation mode. Background SF Symbols that support variable color fall into two categories based on their animation preference: Symbols suited for .symbolVariableValueMode(.color) — layers are highlighted/dimmed by color opacity Symbols suited for .symbolVariableValueMode(.draw) — layers are progressively drawn/erased When .symbolVariableValueMode is not set (i.e., the default mode), I expected the system to automatically choose the appropriate mode for each symbol. What SF Symbols app shows In the SF Symbols app, selecting thermometer.high, enabling variable color, and setting the value to 0.5 with Default mode selected produces a correct and expected result — the symbol renders identically to the explicit Draw mode. What SwiftUI code does In code, when symbolVariableValueMode is not specified (default), symbols from the Draw category receive no visual effect — t
0
0
391
May ’26
Reply to SwiftUI MapKit
Here is a code snippet that lets you tap 2 points on the map to calculate a route and verify that MapPolyline is still rendered below the traffic layer in certain cities, despite using .mapOverlayLevel(level: .aboveRoads). Try highways import SwiftUI import MapKit struct ContentView: View { @State private var position: MapCameraPosition = .region(MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 51.5, longitude: -0.1), latitudinalMeters: 2000, longitudinalMeters: 2000 )) @State private var tappedCoordinates: [CLLocationCoordinate2D] = [] @State private var routePolyline: MKPolyline? = nil @State private var isCalculating = false var body: some View { ZStack(alignment: .bottom) { MapReader { proxy in Map(position: $position) { if let polyline = routePolyline { MapPolyline(polyline) .stroke(.blue, lineWidth: 10) .mapOverlayLevel(level: .aboveRoads) } ForEach(tappedCoordinates.indices, id: .self) { i in Marker((i + 1), coordinate: tappedCoordinates[i]) .tint(i == 0 ? .green : .red) } } .mapSt
May ’26
SwiftUI + AppKit context menu wedges window-level mouse events when the menu's anchor view is deleted by the menu's own action
I'm on macOS 26.4 (SwiftUI + SwiftData + AppKit bridging). I have a SwiftUI canvas where each child view (a card) carries a per-card AppKit context menu via an NSViewRepresentable overlay (a small NSView subclass that overrides menu(for:) and returns an NSMenu whose items invoke a Swift closure). The closure for the Delete item removes the underlying model object. SwiftData mutates → SwiftUI re-emits the canvas → the card containing the menu's anchor NSView unmounts → that anchor NSView is removed from the AppKit view hierarchy. After this happens, the entire window's SwiftUI gestures stop receiving mouse events: pan, zoom, taps on a separate background Color view all go silent. The window's first responder ends up at the NSWindow itself. The wedge persists across switching to a sibling SwiftUI view in the same window (different SwiftData root), so the bad state is at the window/event-routing level, not in any one SwiftUI subtree. The wedge is reliably cle
0
0
572
May ’26
Reply to Core Data Multiple NSEntityDescriptions claim the NSManagedObject subclass
Hi everyone! Is there an update on this issue or the posted feedback? I still run into the same in with the Xcode 25.5 RC and iOS 26.5 RC. What I do is: Rename the first model from Model to ModelV1 Copy the ModelV1 to ModelV2 Add new properties in ModelV2 Create NSStagedMigrationManager All entities are with manual/none generation. As I've already introduced usage of into: context when creating new objects, they are fine. Now the @FetchRequests fail (the one the views) with: Thread 1: executeFetchRequest:error: A fetch request must have an entity.. These are 'solvable' by creating a FetchRequest with an entity: https://developer.apple.com/documentation/swiftui/fetchrequest/init(entity:sortdescriptors:predicate:animation:). However this requires passing around the context and adding inits in a lot of places. These are two WWDC meetings with more info: https://developer.apple.com/videos/play/wwdc2023/10186 https://developer.apple.com/videos/play/wwdc2022/10120 However they don't contain clues what migh
Topic: App & System Services SubTopic: iCloud Tags:
May ’26
Programatically adding to a TextField and moving the TextSelection point in SwiftUI
Hi! I am trying to create a simple SwiftUI TextField, with an external button to add text to the field at the current insertion point (the cursor in the TextField). When I add the text, the cursor (I-Beam) remains at the original insertion point, so I want it to move over to the end of what I added. The trouble is, it sometimes moves further forward or to the end (visibly) but works as if it is still at the point I moved it to. This seems to possibly be due to emojis in the TextField (because, I assume, they are composed of more bytes). Further, sometimes the addition of the text can cause an emoji to appear unexpectedly, I assume because it is combining the bytes in an odd way. So moving the cursor seems to sometimes introduce weird behaviour. This comes from a much larger project, but I have distilled this down to the smallest example project I could. And I have a video to show how it behaves. Here's the main part of the code, and I'll attach an Xcode project: import SwiftUI struct Content
2
0
667
May ’26
error: A NavigationLink is presenting a value of type “String” but there is no matching navigationDestination
please help, i am new to SWIFTUI getting an error: A NavigationLink is presenting a value of type “String” but there is no matching navigationDestination declaration visible from the location of the link. The link cannot be activated. struct debug_navigation_3: View { @State private var path = NavigationPath() @StateObject private var debug_Client_Lead_Data_ListVM = Debug_Client_Lead_Data_List_Model() var body: some View { NavigationStack(path:$path) { VStack { List(debug_Client_Lead_Data_ListVM.Debug_Client_Lead_Data_Rows, id: .self) { curr_clientLeadRequest in NavigationLink(curr_clientLeadRequest.Client_Message, value: curr_clientLeadRequest.Client_Message) } } .navigationDestination(for:Debug_Client_Lead_Data.self) { curr_clientLeadRequest in debug_navigation_3_DetailView(rec_id: Int64(curr_clientLeadRequest.id)) } } .onAppear() { Task { await debug_Client_Lead_Data_ListVM.search(rec_id:Int64(0)) //bring all REST API } } } } // data model import Foundation struct Debug_Client_Lead_Data_Response:
Topic: UI Frameworks SubTopic: SwiftUI
2
0
467
May ’26
How do I dismiss a presented sheet?
I'm developing an app requiring data entry across several devices. My SwiftUI app runs on iOS and iPadOS but I also want to run it on visionOS. I'm using the visionOS simulator. When I enter data in one of my views I use a Form within a .sheet and this works perfectly well on iOS and iPadOS and I can dismiss the sheet by simply tapping the view behind the sheet. On visionOS I click my + button, the sheet appears, I enter the data as usual but after that there is no gesture in the app I can perform with keyboard or mouse that will make the sheet disappear! Do I have to add a Close button for visionOS or is there a way to enable the same interaction that works on iPadOS?
2
0
1.5k
May ’26
Reply to App crashes in CGFontStrikeRelease
Adding a data point to this thread. We're seeing the exact same stack chain — _os_unfair_lock_corruption_abort → _os_unfair_lock_lock_slow → CGFontStrikeGetSize → CGGlyphBuilderUnlockBitmaps → render_glyphs → CA::Transaction::commit → _UIApplicationFlushCATransaction — deterministically reproducing on iPhone 17 Pro Max + iOS 26.4.2 (build 23E261) during a SwiftUI Setup→Session view transition while CoreML models are warming and an AVAudioEngine is starting. Filed as FB22728399 on 2026-05-08, with 6 byte-identical .ips reports and a full sysdiagnose attached. A few additions to the existing reports here: Negative MallocStackLogging result. Crash reproduces with MallocStackLogging + MallocScribble + MallocPreScribble + MallocGuardEdges all simultaneously active. Zero malloc diagnostics fire. The corrupting write is not in user-managed heap. Co-occurring signal. 8× AVAudioBuffer.mm:281 mBuffers[0].mDataByteSize (0) should be non-zero warnings during the same model-compile window in which the lock corrup
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’26
Why doesn't .glassEffect tint render on a Menu in an iOS 26 toolbar?
This is what I am trying to achieve (from the Phone app, similar one is also in Photos) I have a standard SwiftUI Menu in a toolbar with a glass tint applied to indicate the filter is active: Menu { // …filter options } label: { Label(Filter, systemImage: line.3.horizontal.decrease) } .glassEffect(.regular.tint(.accentColor).interactive()) The glass effect doesn't render at all, no tint. The button looks completely unstyled. If I switch the label from Label to Image, the glass renders, but as a stretched oblong pill. I have tried several other combinations too: Also in the Apple's version during hover (iPad) the highlight aligns with the tint itself (see second image above) rather than outside it like in example 3 from the list above: Is there a way to get a Menu's trigger inset tint to look as in the Phone app example?
0
0
292
May ’26
SwiftUI + SpriteKit interop: best practices for HUD overlays in a tile-based puzzle game?
Hey all, I'm building a tile-based puzzle game for iOS and have been experimenting with using SwiftUI for the HUD (score, timer, pause menu, settings sheet) layered on top of a SpriteView that hosts the actual gameplay scene. So far the integration has been smoother than I expected — SpriteView drops cleanly into a ZStack, and I can drive SwiftUI state from the SpriteKit scene via an ObservableObject shared between them. That said, I've run into a few rough edges that I'd love some input on. The biggest one is touch handling: when a SwiftUI overlay (like a semi-transparent pause button) sits over the SpriteView, taps near the edges of the button occasionally get swallowed by the underlying scene, even when the button's hit area looks correct in the view debugger. I've tried .contentShape(Rectangle()) and bumping the frame, which helps but doesn't fully eliminate it. Curious if anyone has landed on a reliable pattern here, especially for transient overlays like toast notifications th
0
0
1.2k
May ’26
Reply to AVPlayerView. Internal constraints conflicts
FWIW: After some experimentation, I've found that setting the AVPlayerView's controlsStyle property to .floating allows the view to load without getting the constraints errors. Of course that means you have to be able to use that style in your UI. And I don't see an equivalent way of making the same change using the AVPlayer in SwiftUI, so you have to use a NSViewRepresentable in a SwiftUI project.
Topic: Media Technologies SubTopic: Video Tags:
Replies
Boosts
Views
Activity
May ’26
Reply to AVPlayerView. Internal constraints conflicts
For what it's worth, I'm seeing the same issue using an AVPlayer in a Mac build of SwiftUI apps. It works fine in iOS.
Topic: Media Technologies SubTopic: Video Tags:
Replies
Boosts
Views
Activity
May ’26
tvOS SwiftUI - Siri "On-Screen Actions" breaks lazy lists
Hey team, This is a weird one, when Siri + On-Screen Actions are enabled in the Apple TV settings (General Settings), LazyVStack experiences severe main-thread hangs and very high CPU usage. The issue only occurs when Siri + On-Screen Actions are enabled in Apple TV device settings (General Settings). Disabling On-Screen Actions completely resolves the issue. The issue has been verified on multiple Apple TV devices, running tvOS 26.3, 26.4 and 26.5. The behavior was not observed in Simulators, only on an actual device. This seems to be caused by some type of accessibility overlap with SwiftUI. Running the below code with On-Screen Actions enabled in the Siri settings will demonstrate a complete hang of the CPU at 100% struct TestData { let id = UUID() var title: String } struct TestView: View { @State private var test: [TestData] = [] var body: some View { ScrollView { LazyVStack { ForEach(self.test, id: .id) { data in Button { } label: { Text(data.title) } } } } .task { var arr: [TestData] = [] for
Replies
0
Boosts
0
Views
483
Activity
May ’26
SF Symbols Variable Color — "Draw" symbols show no effect in Default mode
I've noticed an inconsistency between how the SF Symbols app and SwiftUI code handle variable color for symbols that use the Draw animation mode. Background SF Symbols that support variable color fall into two categories based on their animation preference: Symbols suited for .symbolVariableValueMode(.color) — layers are highlighted/dimmed by color opacity Symbols suited for .symbolVariableValueMode(.draw) — layers are progressively drawn/erased When .symbolVariableValueMode is not set (i.e., the default mode), I expected the system to automatically choose the appropriate mode for each symbol. What SF Symbols app shows In the SF Symbols app, selecting thermometer.high, enabling variable color, and setting the value to 0.5 with Default mode selected produces a correct and expected result — the symbol renders identically to the explicit Draw mode. What SwiftUI code does In code, when symbolVariableValueMode is not specified (default), symbols from the Draw category receive no visual effect — t
Replies
0
Boosts
0
Views
391
Activity
May ’26
Reply to SwiftUI MapKit
Here is a code snippet that lets you tap 2 points on the map to calculate a route and verify that MapPolyline is still rendered below the traffic layer in certain cities, despite using .mapOverlayLevel(level: .aboveRoads). Try highways import SwiftUI import MapKit struct ContentView: View { @State private var position: MapCameraPosition = .region(MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 51.5, longitude: -0.1), latitudinalMeters: 2000, longitudinalMeters: 2000 )) @State private var tappedCoordinates: [CLLocationCoordinate2D] = [] @State private var routePolyline: MKPolyline? = nil @State private var isCalculating = false var body: some View { ZStack(alignment: .bottom) { MapReader { proxy in Map(position: $position) { if let polyline = routePolyline { MapPolyline(polyline) .stroke(.blue, lineWidth: 10) .mapOverlayLevel(level: .aboveRoads) } ForEach(tappedCoordinates.indices, id: .self) { i in Marker((i + 1), coordinate: tappedCoordinates[i]) .tint(i == 0 ? .green : .red) } } .mapSt
Replies
Boosts
Views
Activity
May ’26
SwiftUI + AppKit context menu wedges window-level mouse events when the menu's anchor view is deleted by the menu's own action
I'm on macOS 26.4 (SwiftUI + SwiftData + AppKit bridging). I have a SwiftUI canvas where each child view (a card) carries a per-card AppKit context menu via an NSViewRepresentable overlay (a small NSView subclass that overrides menu(for:) and returns an NSMenu whose items invoke a Swift closure). The closure for the Delete item removes the underlying model object. SwiftData mutates → SwiftUI re-emits the canvas → the card containing the menu's anchor NSView unmounts → that anchor NSView is removed from the AppKit view hierarchy. After this happens, the entire window's SwiftUI gestures stop receiving mouse events: pan, zoom, taps on a separate background Color view all go silent. The window's first responder ends up at the NSWindow itself. The wedge persists across switching to a sibling SwiftUI view in the same window (different SwiftData root), so the bad state is at the window/event-routing level, not in any one SwiftUI subtree. The wedge is reliably cle
Replies
0
Boosts
0
Views
572
Activity
May ’26
Reply to Core Data Multiple NSEntityDescriptions claim the NSManagedObject subclass
Hi everyone! Is there an update on this issue or the posted feedback? I still run into the same in with the Xcode 25.5 RC and iOS 26.5 RC. What I do is: Rename the first model from Model to ModelV1 Copy the ModelV1 to ModelV2 Add new properties in ModelV2 Create NSStagedMigrationManager All entities are with manual/none generation. As I've already introduced usage of into: context when creating new objects, they are fine. Now the @FetchRequests fail (the one the views) with: Thread 1: executeFetchRequest:error: A fetch request must have an entity.. These are 'solvable' by creating a FetchRequest with an entity: https://developer.apple.com/documentation/swiftui/fetchrequest/init(entity:sortdescriptors:predicate:animation:). However this requires passing around the context and adding inits in a lot of places. These are two WWDC meetings with more info: https://developer.apple.com/videos/play/wwdc2023/10186 https://developer.apple.com/videos/play/wwdc2022/10120 However they don't contain clues what migh
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
May ’26
Programatically adding to a TextField and moving the TextSelection point in SwiftUI
Hi! I am trying to create a simple SwiftUI TextField, with an external button to add text to the field at the current insertion point (the cursor in the TextField). When I add the text, the cursor (I-Beam) remains at the original insertion point, so I want it to move over to the end of what I added. The trouble is, it sometimes moves further forward or to the end (visibly) but works as if it is still at the point I moved it to. This seems to possibly be due to emojis in the TextField (because, I assume, they are composed of more bytes). Further, sometimes the addition of the text can cause an emoji to appear unexpectedly, I assume because it is combining the bytes in an odd way. So moving the cursor seems to sometimes introduce weird behaviour. This comes from a much larger project, but I have distilled this down to the smallest example project I could. And I have a video to show how it behaves. Here's the main part of the code, and I'll attach an Xcode project: import SwiftUI struct Content
Replies
2
Boosts
0
Views
667
Activity
May ’26
error: A NavigationLink is presenting a value of type “String” but there is no matching navigationDestination
please help, i am new to SWIFTUI getting an error: A NavigationLink is presenting a value of type “String” but there is no matching navigationDestination declaration visible from the location of the link. The link cannot be activated. struct debug_navigation_3: View { @State private var path = NavigationPath() @StateObject private var debug_Client_Lead_Data_ListVM = Debug_Client_Lead_Data_List_Model() var body: some View { NavigationStack(path:$path) { VStack { List(debug_Client_Lead_Data_ListVM.Debug_Client_Lead_Data_Rows, id: .self) { curr_clientLeadRequest in NavigationLink(curr_clientLeadRequest.Client_Message, value: curr_clientLeadRequest.Client_Message) } } .navigationDestination(for:Debug_Client_Lead_Data.self) { curr_clientLeadRequest in debug_navigation_3_DetailView(rec_id: Int64(curr_clientLeadRequest.id)) } } .onAppear() { Task { await debug_Client_Lead_Data_ListVM.search(rec_id:Int64(0)) //bring all REST API } } } } // data model import Foundation struct Debug_Client_Lead_Data_Response:
Topic: UI Frameworks SubTopic: SwiftUI
Replies
2
Boosts
0
Views
467
Activity
May ’26
Reply to Detect SD Card
Its a shame its so slow. It overcomes many of the drawbacks of using native SwiftUI functionality but its orders of magnitude slower.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
May ’26
How do I dismiss a presented sheet?
I'm developing an app requiring data entry across several devices. My SwiftUI app runs on iOS and iPadOS but I also want to run it on visionOS. I'm using the visionOS simulator. When I enter data in one of my views I use a Form within a .sheet and this works perfectly well on iOS and iPadOS and I can dismiss the sheet by simply tapping the view behind the sheet. On visionOS I click my + button, the sheet appears, I enter the data as usual but after that there is no gesture in the app I can perform with keyboard or mouse that will make the sheet disappear! Do I have to add a Close button for visionOS or is there a way to enable the same interaction that works on iPadOS?
Replies
2
Boosts
0
Views
1.5k
Activity
May ’26
Reply to Detect SD Card
Yes - it was my lack of familiarity with the communication between a SwiftUI application and this type of framework.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
May ’26
Reply to App crashes in CGFontStrikeRelease
Adding a data point to this thread. We're seeing the exact same stack chain — _os_unfair_lock_corruption_abort → _os_unfair_lock_lock_slow → CGFontStrikeGetSize → CGGlyphBuilderUnlockBitmaps → render_glyphs → CA::Transaction::commit → _UIApplicationFlushCATransaction — deterministically reproducing on iPhone 17 Pro Max + iOS 26.4.2 (build 23E261) during a SwiftUI Setup→Session view transition while CoreML models are warming and an AVAudioEngine is starting. Filed as FB22728399 on 2026-05-08, with 6 byte-identical .ips reports and a full sysdiagnose attached. A few additions to the existing reports here: Negative MallocStackLogging result. Crash reproduces with MallocStackLogging + MallocScribble + MallocPreScribble + MallocGuardEdges all simultaneously active. Zero malloc diagnostics fire. The corrupting write is not in user-managed heap. Co-occurring signal. 8× AVAudioBuffer.mm:281 mBuffers[0].mDataByteSize (0) should be non-zero warnings during the same model-compile window in which the lock corrup
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’26
Why doesn't .glassEffect tint render on a Menu in an iOS 26 toolbar?
This is what I am trying to achieve (from the Phone app, similar one is also in Photos) I have a standard SwiftUI Menu in a toolbar with a glass tint applied to indicate the filter is active: Menu { // …filter options } label: { Label(Filter, systemImage: line.3.horizontal.decrease) } .glassEffect(.regular.tint(.accentColor).interactive()) The glass effect doesn't render at all, no tint. The button looks completely unstyled. If I switch the label from Label to Image, the glass renders, but as a stretched oblong pill. I have tried several other combinations too: Also in the Apple's version during hover (iPad) the highlight aligns with the tint itself (see second image above) rather than outside it like in example 3 from the list above: Is there a way to get a Menu's trigger inset tint to look as in the Phone app example?
Replies
0
Boosts
0
Views
292
Activity
May ’26
SwiftUI + SpriteKit interop: best practices for HUD overlays in a tile-based puzzle game?
Hey all, I'm building a tile-based puzzle game for iOS and have been experimenting with using SwiftUI for the HUD (score, timer, pause menu, settings sheet) layered on top of a SpriteView that hosts the actual gameplay scene. So far the integration has been smoother than I expected — SpriteView drops cleanly into a ZStack, and I can drive SwiftUI state from the SpriteKit scene via an ObservableObject shared between them. That said, I've run into a few rough edges that I'd love some input on. The biggest one is touch handling: when a SwiftUI overlay (like a semi-transparent pause button) sits over the SpriteView, taps near the edges of the button occasionally get swallowed by the underlying scene, even when the button's hit area looks correct in the view debugger. I've tried .contentShape(Rectangle()) and bumping the frame, which helps but doesn't fully eliminate it. Curious if anyone has landed on a reliable pattern here, especially for transient overlays like toast notifications th
Replies
0
Boosts
0
Views
1.2k
Activity
May ’26