Search results for

“swiftui”

17,106 results found

Post

Replies

Boosts

Views

Activity

Workarounds for Xcode previews errors: Cannot preview in this file - Failed to Launch
I have started to have issues with SwiftUI previews of iOS apps with projects under the Documents folder. I have experimented that in Xcode 26.4 and I am still seeing it in 26.5. The error is: Cannot preview in this file. Failed to launch xyz.abc.TestApp Looking at the diagnostics, Xcode gets a permission denied error when trying to open /Users/me/Documents/path/to/TestApp/DerivedData/TestApp/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/Objects-normal/arm64/ContentView.1.preview-thunk-launch.o Error details below. Note that I have set DerivedData folders relative to the projects' roots. Additional information: I get errors on freshly created iOS projects, just trying to preview the default ContentView. Xcode has full disk access set in System Preferences > Privacy & Security. I have cleaned build folders, deleted the simulators, Xcode itself, cleared various caches, restarted and reinstalled Xcode to no avail. Checking Editor > Canvas > Use Legacy Preview
4
0
203
2w
Overlay window above all windows, even when moving spaces
Hi! I would like to overlay a macOS application window above all windows, even when moving spaces or moving to a fullscreen app, similar in function to the DropOver app for macOS. What I have tried: Overwriting the default app delegate in SwiftUI and creating the NSWindow myself. Then setting the window.collectionBehavior to [.canJoinAllApplications, .canJoinAllSpaces, .fullScreenAuxiliary] and the window.level to .floating or .statusBar. This works for moving between Spaces, but still does not display above apps in fullscreen mode. I also registered a notification observer for NSWorkspace.activeSpaceDidChangeNotification, where I call window.orderFrontRegardless() to always have my window frontmost. Still not displaying above fullscreen apps. What am I missing to make this work? Best regards
2
0
152
2w
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:
2w
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
215
2w
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
164
2w
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
2w
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
334
2w
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:
2w
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
448
2w
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
1
0
283
2w
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?
1
0
914
2w
Workarounds for Xcode previews errors: Cannot preview in this file - Failed to Launch
I have started to have issues with SwiftUI previews of iOS apps with projects under the Documents folder. I have experimented that in Xcode 26.4 and I am still seeing it in 26.5. The error is: Cannot preview in this file. Failed to launch xyz.abc.TestApp Looking at the diagnostics, Xcode gets a permission denied error when trying to open /Users/me/Documents/path/to/TestApp/DerivedData/TestApp/Build/Intermediates.noindex/TestApp.build/Debug-iphonesimulator/TestApp.build/Objects-normal/arm64/ContentView.1.preview-thunk-launch.o Error details below. Note that I have set DerivedData folders relative to the projects' roots. Additional information: I get errors on freshly created iOS projects, just trying to preview the default ContentView. Xcode has full disk access set in System Preferences > Privacy & Security. I have cleaned build folders, deleted the simulators, Xcode itself, cleared various caches, restarted and reinstalled Xcode to no avail. Checking Editor > Canvas > Use Legacy Preview
Replies
4
Boosts
0
Views
203
Activity
2w
Overlay window above all windows, even when moving spaces
Hi! I would like to overlay a macOS application window above all windows, even when moving spaces or moving to a fullscreen app, similar in function to the DropOver app for macOS. What I have tried: Overwriting the default app delegate in SwiftUI and creating the NSWindow myself. Then setting the window.collectionBehavior to [.canJoinAllApplications, .canJoinAllSpaces, .fullScreenAuxiliary] and the window.level to .floating or .statusBar. This works for moving between Spaces, but still does not display above apps in fullscreen mode. I also registered a notification observer for NSWorkspace.activeSpaceDidChangeNotification, where I call window.orderFrontRegardless() to always have my window frontmost. Still not displaying above fullscreen apps. What am I missing to make this work? Best regards
Replies
2
Boosts
0
Views
152
Activity
2w
Reply to Xcode 26.4: IBOutlets/IBActions gutter circles missing — cannot connect storyboard to code (works in 26.3)
In the same way, @IBDesignable, @IBInspectable have disappeared some time ago. Is it only with objC code or Swift as well ? I do hope I'm wrong, but sometimes, looks like they are silently killing IB to force developers to SwiftUI. That would be very very negative evolution.
Replies
Boosts
Views
Activity
2w
How to optimize SwiftData performance in large lists?
I’m building a SwiftUI application using SwiftData for local storage. When loading large lists with images, scrolling performance becomes slower. What are the best practices to optimize SwiftData fetch performance in SwiftUI apps?
Replies
1
Boosts
0
Views
223
Activity
2w
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
2w
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
2w
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
215
Activity
2w
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
164
Activity
2w
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
2w
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
334
Activity
2w
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
2w
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
448
Activity
2w
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
1
Boosts
0
Views
283
Activity
2w
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
2w
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
1
Boosts
0
Views
914
Activity
2w