Provide views, controls, and layout structures for declaring your app's user interface using SwiftUI.

Posts under SwiftUI tag

200 Posts

Post

Replies

Boosts

Views

Activity

I think I found a bug in SwiftUI on macOS 15.4 that crashes apps
We've been receiving crash reports for our app from users that have upgraded to macOS 15.4. I have upgraded my developer machine and immediately was able to reproduce the crash. I was able to create a minimal reproducible scenario. The following view crashes the app when sheet is presented with this trace: The window has been marked as needing another Update Constraints in Window pass, but it has already had more Update Constraints in Window passes than there are views in the window. <_TtC7SwiftUIP33_7B5508BFB2B0CAF1E28E206F2014E66B23SheetPresentationWindow: 0x1111074c0> 0x9bd (2493) {{0, 0}, {100, 108}} en ( 0 CoreFoundation 0x000000018bdfddf0 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018b8c2b60 objc_exception_throw + 88 2 CoreFoundation 0x000000018bdfdce0 +[NSException exceptionWithName:reason:userInfo:] + 0 3 AppKit 0x000000019043d394 -[NSWindow(NSDisplayCycle) _postWindowNeedsUpdateConstraints] + 1788 4 AppKit 0x000000018f9f8c08 -[NSView _informContainerThatSubviewsNeedUpdateConstraints] + 64 5 AppKit 0x000000018f9f8b8c -[NSView setNeedsUpdateConstraints:] + 468 6 SwiftUI 0x00000001bc0e5110 $s7SwiftUI13NSHostingViewC14setNeedsUpdate33_32B6F54841135BB466A5C1362EB89D05LLyyF + 80 7 SwiftUI 0x00000001bc101f28 $s7SwiftUI13NSHostingViewC13requestUpdate5afterySd_tF + 616 Conditions that are important: accessing a publishable property inside the sheet .sheet() on a component that is wrapped in another (VStack is required in the example provided) being used inside NavigationSplitView Presents of @Environment(\.openURL. Doesn't have to be used, simply present on the view. struct ContentView: View { @Environment(\.openURL) private var open @State var who = "world" @State var shown = false var body: some View { NavigationSplitView(sidebar: { Text("Hello, world") }, detail: { VStack(spacing: 20) { Button("Kill me pls") { shown = true } .frame(width: 110, height: 110) .sheet(isPresented: $shown) { VStack { HStack() { Text("Hello, \(who)!") } } .presentationBackground(.thinMaterial) } } }) } }
2
0
124
Apr ’25
Text is truncated with certain font sizes on iOS 17+, but not on iOS 16
’m experiencing an issue where a Text view is unexpectedly truncated with certain font sizes (e.g., .body) on iOS 17 and later. This does not occur on iOS 16. I’ve applied .fixedSize(horizontal: false, vertical: true) to allow the text to grow vertically, but it still doesn’t show the entire content. Depending on the text content or font size, it sometimes works, but not always. How can I ensure the full text is displayed correctly on iOS 17+? Here is a minimal reproducible SwiftUI example: let sampleText1 = """ これはサンプルのテキストです、 ・箇条書き1 ・箇条書き2 であかさたなクロを送り、 アアを『ああああいいいい』フライパンに入れ、あかさたなです😋 """ let sampleText2 = """ 【旬|最高級】北海道産 生サンマ 釜飯 ----- Aaa iii uuu """ struct ContentView: View { var body: some View { ScrollView { VStack(alignment: .leading, spacing: 10) { HStack { MessageTextView(text: sampleText1) .layoutPriority(100) Spacer() } HStack { MessageTextView(text: sampleText2) .layoutPriority(100) Spacer() } } } } } struct MessageTextView: View { var text: String var body: some View { Text(text) .fixedSize(horizontal: false, vertical: true) .font(.body) .padding(.leading, 16) .padding(.trailing, 16) .padding(.top, 8) .padding(.bottom, 8) } } img1 img2
4
0
147
Apr ’25
Question about BGAppRefreshTask approach for medication scheduling app
I'm developing a medication scheduling app similar to Apple Health's Medications feature, and I'd like some input on my current approach to background tasks. In my app, when a user creates a medication, I generate ScheduledDose objects (with corresponding local notifications) for the next 2 weeks and save them to SwiftData. To ensure this 2-week window stays current, I've implemented a BGAppRefreshTask that runs daily to generate new doses as needed. My concern is whether BGAppRefreshTask is the appropriate mechanism for this purpose. Since I'm not making any network requests but rather generating and storing local data, I'm questioning if this is the right approach. I'm also wondering how Apple Health's Medications feature handles this kind of scheduling. Their app seems to maintain future doses regardless of app usage patterns. Has anyone implemented something similar or can suggest the best background execution API for this type of scenario? Thanks for any guidance you can provide.
2
0
134
Apr ’25
SwiftData and @Query to find all records for the current date of a multidatepicker (Set = [])
I’m trying to build a CRUD app using SwiftData, @Query model and multidatepicker. The data from a multidatepicker is stored or persists in SwiftData as Set = []. My current dilemma is how to use SwiftData and @Query model Predicate to find all records on the current date. I can’t find any SwiftData documentation or examples @Query using Set = []. My CRUD app should retrieve all records for the current date. Unfortunately, I don’t know the correct @Query model syntax for Set = [].
0
0
62
Apr ’25
Calling from Watchos
I am working with a watchOS app in SwiftUI, and I am using the following code to dial a phone number from the watch: var number = "123456789" if let telURL = URL(string: "tel:\(number)") { let wkExtension = WKExtension.shared() wkExtension.openSystemURL(telURL) } The issue is that when I try to dial a number starting with a * (asterisk) or # (hash), it doesn't work. When dialing a regular number, it works fine. Is there any way to get this to work?
1
0
119
Apr ’25
dropDestination does not work inside List
I've discovered an issue with using iOS 16's Transferable drag-and-drop APIs for SwiftUI. The dropDestination modifier does not work when applied to a subview of a List. This code below will not work, unless you replace the List with a VStack or any other container (which, of course, removes all list-specific rendering). The draggable modifier will still work and the item will drag, but the dropDestination view won't react to it and neither closure will be called. struct MyView: View { var body: some View { List { Section { Text("drag this title") .font(.largeTitle) .draggable("a title") } Section { Color.pink .frame(width: 400, height: 400) .dropDestination(for: String.self) { receivedTitles, location in true } isTargeted: { print($0) } } } } } Has anyone encountered this bug and perhaps found a workaround?
8
0
3.5k
Apr ’25
how to achieve "concave in" glass view look?
I have been trying to implement this look where a component looks "pushed in" but I could not find any resources regarding this effect. The closest I got was a combination of a RoundedRectangle and .glassBackgroundEffect(), but this makes the view look pushed out, instead of pushed in. I was wondering if this is achievable in SwiftUI level, or even in UIKit level.
1
0
111
Apr ’25
SwiftData "Auto Inserts" array into ModelContext
Definitely one of the stranger quirks of SwiftData I've come across. I have a ScriptView that shows Line entities related to a Production, and a TextEnterScriptView that’s presented in a sheet to input text. I’m noticing that every time I type in the TextEditor within TextEnterScriptView, a new Line shows up in ScriptView — even though I haven’t explicitly inserted it into the modelContext. I'm quite confused because even though I’m only assigning a new Line to a local @State array in TextEnterScriptView, every keystroke in the TextEditor causes a duplicate Line to appear in ScriptView. In other words, Why is SwiftData creating new Line entities every time I type in the TextEditor, even though I’m only assigning to a local @State array and not explicitly inserting them into the modelContext? Here is my minimal reproducible example: import SwiftData import SwiftUI @main struct testApp: App { var body: some Scene { WindowGroup { ContentView() .modelContainer(for: Line.self, isAutosaveEnabled: false) } } } struct ContentView: View { @Environment(\.modelContext) var modelContext @Query(sort: \Production.title) var productions: [Production] var body: some View { NavigationStack { List(productions) { production in NavigationLink(value: production) { Text(production.title) } } .navigationDestination(for: Production.self) { production in ScriptView(production: production) } .toolbar { Button("Add", systemImage: "plus") { let production = Production(title: "Test \(productions.count + 1)") modelContext.insert(production) do { try modelContext.save() } catch { print(error) } } } .navigationTitle("Productions") } } } struct ScriptView: View { @Query private var lines: [Line] let production: Production @State private var isShowingSheet: Bool = false var body: some View { List { ForEach(lines) { line in Text(line.content) } } .toolbar { Button("Show Sheet") { isShowingSheet.toggle() } } .sheet(isPresented: $isShowingSheet) { TextEnterScriptView(production: production) } } } struct TextEnterScriptView: View { @Environment(\.dismiss) var dismiss @State private var text = "" @State private var lines: [Line] = [] let production: Production var body: some View { NavigationStack { TextEditor(text: $text) .onChange(of: text, initial: false) { lines = [Line(content: "test line", production: production)] } .toolbar { Button("Done") { dismiss() } } } } } @Model class Production { @Attribute(.unique) var title: String @Relationship(deleteRule: .cascade, inverse: \Line.production) var lines: [Line] = [] init(title: String) { self.title = title } } @Model class Line { var content: String var production: Production? init(content: String, production: Production?) { self.content = content self.production = production } }
1
0
68
Apr ’25
Can SwiftUI on macOS create an NSComboButton?
Without resorting to NSViewRepresentable, is there a view or view modifier in SwiftUI that can create an NSComboButton on macOS? NSComboButton was introduced in macOS 13 and is (relatively) new to AppKit: Apple Developer - NSComboButton I only require support on macOS for this control. Note that this is not to be confused with NSComboBox, which is a completely different control.
1
0
108
Apr ’25
Can @Query and ModelActor co-exist? How?
Context: The SwiftUI @Query macro has an internal modelContext. The ModelActor also has a modelContext, from which the data should be read/written. Issue: When writing to @Model data fetched with @Query macro using a ModelActor, it will crash in the most not-obvious ways. Also, fetching @Model with ModelActor will result in errors in Swift 6 since @Model aren't sendable. Problem to Solve: - How to write a good amount of data to SwiftData/CoreData without blocking the UI thread? Would the recommendation from the Apple team be that a large amount of data should be read/written with ModelActor and a small amount should be done with the @Query's internal modelContext ?
1
0
119
Apr ’25
Should you access @State properties from an NSViewController (AppKit / SwiftUI Integration)?
I'm currently working on a project to integrate some SwiftUI components into an existing AppKit application. The application makes extensive use of NSViewControllers. I can easily bridge between AppKit and SwiftUI using a view model that conforms to ObservableObject and is shared between the NSViewController and the SwiftUI View. But it's kind of tedious creating a view model for every view. Is it "safe" and "acceptable" for the NSViewController to "hold on" to the SwiftUI View that it creates and then access its @State or @StateObject properties? The lifecycle of DetailsView, a SwiftUI View, isn't clear to me when viewed through the lens of an NSViewController. Consider the following: import AppKit import SwiftUI struct DetailsView: View { @State var details: String = "" var body: some View { Text(details) } } final class ViewController: NSViewController { private let detailsView: DetailsView init() { self.detailsView = DetailsView() super.init(nibName: nil, bundle: nil) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { view.addSubview(NSHostingView(rootView: detailsView)) } func updateDetails(_ details: String) { // Is this 'safe' and 'acceptable'? self.detailsView.details = details } } Is the view controller guaranteed to always be updating the correct @State property or is there a chance that the view controller's reference to it somehow becomes stale because of a SwiftUI update?
2
0
96
Apr ’25
Memory leak using .onSubmit on TextField in SwiftU
I am getting memory leak when using .onSubmit view modifier on TextField. Here is a simplified reproducible example: struct ListView: View { var body: some View { NavigationStack { List(0..<100) { i in NavigationLink("Select \(i)", value: i) } .navigationDestination(for: Int.self) { selection in DetailView() .navigationTitle("Page: \(selection)") } } } } struct DetailView: View { @State private var viewModel = DetailViewModel() var body: some View { TextField( "", text: $viewModel.text, prompt: Text("Type in") ) .padding() .onSubmit { print(viewModel.text) } } } @Observable final class DetailViewModel { var text: String = "" deinit { print("Deinit \(Self.self)") } } Navigate to DetailView by selecting a row on ListView page and start typing in TextField, hit the submit button on keyboard and this DetailView with DetailViewModel will be leaked after navigating back to ListView, deinit will not be called. Commenting out .onSubmit {} part fixes the leak. What I observed also, is that once I open the same page or other, It will create new DetailView instance with it's view model and previously leaked one will be released, possible indicating that system somehow holds the last active TextField until new one has become active. I tried calling UIApplication.shared.resignFirstResponder() in onDissapear{} but this does not fix the leak. Only way the leak is fixed, is by using deprecated TextField initializer: init(_ titleKey: LocalizedStringKey, text: Binding<String>, onCommit: @escaping () -> Void) where onCommit is essentially doing the same as onSubmit.
3
1
255
Apr ’25
Animated scale effect causes NSCursor to reset in SwiftUI macOS app
For my macOS app, I'm trying to change the mouse cursor to a pointing hand while hovering over a specific view. However, when the view is scaled with an animation triggered by hovering (using .scaleEffect() and .animation()), the cursor doesn't change as expected. Is there any workaround to fix this? This is a sample code: struct ContentView: View { @State private var hovering = false var body: some View { VStack { Text("Hover me") .padding() .background(hovering ? Color.blue : Color.gray) .scaleEffect(hovering ? 1.2 : 1.0) .animation(.linear(duration: 0.2), value: hovering) .onHover { hovering in self.hovering = hovering if hovering { NSCursor.pointingHand.push() } else { NSCursor.pop() } } } .frame(width: 200, height: 200) } } This is how it works: As you can see, when the pointer enters the view, the cursor changes momentarily before reverting back to the arrow icon. I also tried using NSTrackingArea with an NSView placed over the view, but it did not solve the issue. It might be that the combination of .scaleEffect() and .animation() is causing a forced cursor reset (possibly related to the use of NSWindow.disableCursorRects() or something similar). However, I'm not entirely sure. Any insights or suggestions would be greatly appreciated. Thanks!
2
0
101
Apr ’25
.focusEffectDisabled(true) not working
Hi everyone, I'm working on a tvOS app using SwiftUI, and I want to disable the focus effect (the default focus glow/bounce) on a specific Button. According to the documentation: /// - Parameter disabled: A Boolean value that determines whether this view /// can display focus effects. /// - Returns: A view that controls whether focus effects can be displayed /// in this view. I used .focusEffectDisabled(true) on the Button, expecting the focus style to be completely disabled for that view. However, this doesn’t seem to have any effect in my tvOS 17+ app – the button still shows the default focus visual effect when focused. Here’s a simplified example: Button("Click Me") { // action } .focusEffectDisabled(true) This still shows the bounce/glow focus effect. Am I missing something, or is this a bug? Has anyone managed to fully disable the focus effect for a view (especially Button) in tvOS using SwiftUI? Any workarounds or additional modifiers I should apply? Thanks in advance!
2
0
91
Apr ’25
Navigation broken in iOS 18.4
All of a sudden, after iOS 18.4 was released, I am having tons of navigation problems in my app in production. Buttons navigating to empty pages, views seeming to 'freeze', top navigation bar mismatched with the content of the page. It seems that iOS 18.4 broke a critical piece of UIKit + SwiftUI bridging functionality that my project relies on. My application is written with both UIKit and SwiftUI components. Here is a breakdown of my setup: UIApplicationDelegate > UIWindow > rootViewController of window is a UITabBarController > each tab is a UINavigationController rootViewController of nav controller is a UIHostingController > rootView of the hosting controller is a SwiftUI View In my SwiftUI views, I have been using NavigationLink for horizontal 'push' style navigation in my SwiftUI views. I do not use NavigationView, I only rely on the bridging capabilities of UINavigationController to action on my NavigationLinks. This has never been an issue, until iOS 18.4 was released. Now, when running iOS 18.4, I am having all sorts of unexpected behavior in the UI. I will break down 2 of these use cases here: Use case A: In one of my SwiftUI views, I have a ForEach for which each element's view is a NavigationLink. This is using the NavigationLink(_ destination:,label:) initializer. Navigating forward from here works/looks normal. However, once I try to navigate backward from that destination (tap the 'Back' button in top left), the view goes blank and the navigation bar at the top of the page (which is maintained by the UINavigationController instance) does not change. If I call popToRootViewController on that nav controller, the navigation bar at the top of the page returns to its normal state, but the view is still blank. It is not until after I have called popToRootViewController, and then navigate to a different tab of the UITabBarController and return to the initial tab, does the SwiftuI content view (the one with the ForEach) finally redraw and the view hierarchy is restored. Here is a warning that is logged in the console when I tap the 'Back ' button: Top view controller's view unexpectedly not in window for navigation transition. Skipping layout. nav = <UINavigationController: 0x1110bbe00>, topVC = <TtGC7SwiftUI19UIHostingControllerV5MyApp10MyPage: 0x106814e00> EDIT: If I replace the NavigationLink with a call to UINavigationController.pushViewController, I am still seeing the exact same behavior. Pressing back button makes the view empty > need to pop to root view controller and switch tabs in order to restore the view. Use case B Another instance of this issue happens whenever I try to use a NavigationLink inside of a view that itself was the destination of a NavigationLink in its parent view (i.e.: Root view > detail view > sub-detail view). For example, take the detail view destination in use case A. I have tapped a NavigationLink from the ForEach and landed on the detail view. Again, so far things work/look normal. Now, if I tap on another NavigationLink from that detail view, the view does not transition to the new page. The top navigation bar does transition, and shows the title and actions associated with this second destination. However, the view of this second destination is not displayed. It is worth noting that the same warning I mentioned above is also logged when I tap the NavigationLink to navigate to this second destination. Top view controller's view unexpectedly not in window for navigation transition. Skipping layout. nav = <UINavigationController: 0x109859400>, topVC = <TtGC7SwiftUI19UIHostingControllerVVS_19BridgedPresentation8RootView: 0x300ab8000> Strangely, if I switch to a different tab of the UITabBarController and back to the initial tab, this second destination's view is successfully rendered. It seems that switching tabs in this UITabBarController is calling something in either SwiftUI or UIKit that is redrawing my views. Conclusion This is a serious issue with UIKit + SwiftUI bridging support. I have never had problems like this until devices started running iOS 18.4, and there is nothing in the iOS 18.4 changelog that suggests this was an intentional change. All of a sudden, after updating to the latest iOS version, my app is totally broken. I want to be clear that I'm not using deprecated NavigationLink methods in these instances. My app's minimum deployment target is iOS 16. I know that there are more modern navigation APIs like navigation stack, etc. I am looking for answers about my use case: whether it is officially unsupported as of iOS 18.4, whether this setup should be supported and this is indeed some sort of bug in iOS, or anything in-between. I'm happy to provide formatted code if needed for discussion purposes. This is about my entire app's view hierarchy so there are a lot of disparate lines of code that make up this problem.
1
10
253
Apr ’25
Unable to Write to App Group Shared Container on Device
Hi everyone, I'm facing an issue where I cannot write a file to a shared App Group container in my tvOS app when running on a real device. My code works perfectly on the simulator, but fails on a physical device with a permissions error. I’ve set up an App Group with a custom identifier (e.g., group.<my.identifier>), and it’s correctly configured in the Capabilities section of Xcode for both my main app and widget targets. Here’s the code I’m using to save a test file: func saveTestFile() { guard let groupURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.<my.identifier>") else { print("Couldn't access the Group URL.") return } let containerURL = groupURL.appendingPathComponent("Library", isDirectory: true) if FileManager.default.isWritableFile(atPath: containerURL.path) { print("Directory IS writable") } else { print("Directory IS NOT writable") } let fileURL = containerURL.appendingPathComponent("test.txt") let content = "Hello App Group!" do { try content.write(to: fileURL, atomically: true, encoding: .utf8) print("File test.txt is saved at: \(fileURL.path)") } catch { print("Error while saving the file: \(error)") } } Console: Directory IS NOT writable Error while saving the file: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “test.txt” in the folder “”." UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup//Library/test.txt, NSURL=file:///private/var/mobile/Containers/Shared/AppGroup//Library/test.txt, NSUnderlyingError=0x14387fbe0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} I’ve tried saving the file in different subdirectories within the App Group container: Directly in groupURL (root of the container). In groupURL.appendingPathComponent("Library"). In groupURL.appendingPathComponent("Caches"). Do you have any ideas what is the problem? Thanks in advance for any help!
1
0
115
Apr ’25
SwiftData Many-To-Many Relationship: Failed to fulfill link PendingRelationshipLink
Hi there, I got two models here: Two Models, with Many-To-Many Relationship @Model final class PresetParams: Identifiable { @Attribute(.unique) var id: UUID = UUID() var positionX: Float = 0.0 var positionY: Float = 0.0 var positionZ: Float = 0.0 var volume: Float = 1.0 @Relationship(deleteRule: .nullify, inverse: \Preset.presetAudioParams) var preset = [Preset]() init(position: SIMD3<Float>, volume: Float) { self.positionX = position.x self.positionY = position.y self.positionZ = position.z self.volume = volume self.preset = [] } var position: SIMD3<Float> { get { return SIMD3<Float>(x: positionX, y: positionY, z: positionZ) } set { positionX = newValue.x positionY = newValue.y positionZ = newValue.z } } } @Model final class Preset: Identifiable { @Attribute(.unique) var id: UUID = UUID() var presetName: String var presetDesc: String? var presetAudioParams = [PresetParams]() // Many-To-Many Relationship. init(presetName: String, presetDesc: String? = nil) { self.presetName = presetName self.presetDesc = presetDesc self.presetAudioParams = [] } } To be honest, I don't fully understand how the @Relationship thing works properly in a Many-To-Many relationship situation. Some tutorials suggest that it's required on the "One" side of an One-To-Many Relationship, while the "Many" side doesn't need it. And then there is an ObservableObject called "ModelActors" to manage all ModelActors, ModelContainer, etc. ModelActors, ModelContainer... class ModelActors: ObservableObject { static let shared: ModelActors = ModelActors() let sharedModelContainer: ModelContainer private init() { var schema = Schema([ // ... Preset.self, PresetParams.self, // ... ]) do { sharedModelContainer = try ModelContainer(for: schema, migrationPlan: MigrationPlan.self) } catch { fatalError("Could not create ModelContainer: \(error.localizedDescription)") } } } And there is a migrationPlan: MigrationPlan // MARK: V102 // typealias ... // MARK: V101 typealias Preset = AppSchemaV101.Preset typealias PresetParams = AppSchemaV101.PresetParams // MARK: V100 // typealias ... enum MigrationPlan: SchemaMigrationPlan { static var schemas: [VersionedSchema.Type] { [ AppSchemaV100.self, AppSchemaV101.self, AppSchemaV102.self, ] } static var stages: [MigrationStage] { [AppMigrateV100toV101, AppMigrateV101toV102] } static let AppMigrateV100toV101 = MigrationStage.lightweight(fromVersion: AppSchemaV100.self, toVersion: AppSchemaV101.self) static let AppMigrateV101toV102 = MigrationStage.lightweight(fromVersion: AppSchemaV101.self, toVersion: AppSchemaV102.self) } // MARK: Here is the AppSchemaV101 enum AppSchemaV101: VersionedSchema { static var versionIdentifier: Schema.Version = Schema.Version(1, 0, 1) static var models: [any PersistentModel.Type] { return [ // ... Preset.self, PresetParams.self ] } } Fails on iOS 18.3.x: "Failed to fulfill link PendingRelationshipLink" So I expected the SwiftData subsystem to work correctly with version control. A good news is that on iOS 18.1 it does work. But it fails on iOS 18.3.x with a fatal Error: "SwiftData/SchemaCoreData.swift:581: Fatal error: Failed to fulfill link PendingRelationshipLink(relationshipDescription: (<NSRelationshipDescription: 0x30377fe80>), name preset, isOptional 0, isTransient 0, entity PresetParams, renamingIdentifier preset, validation predicates (), warnings (), versionHashModifier (null)userInfo {}, destination entity Preset, inverseRelationship (null), minCount 0, maxCount 0, isOrdered 0, deleteRule 1, destinationEntityName: "Preset", inverseRelationshipName: Optional("presetAudioParams")), couldn't find inverse relationship 'Preset.presetAudioParams' in model" Fails on iOS 17.5: Another Error I tested it on iOS 17.5 and found another issue: Accessing or mutating the "PresetAudioParams" property causes the SwiftData Macro Codes to crash, affecting both Getter and Setter. It fails with an error: "EXC_BREAKPOINT (code=1, subcode=0x1cc1698ec)" Tweaking the @Relationship marker and ModelContainer settings didn't fix the problem.
1
0
130
Apr ’25
Severe hangs with LazyHStack inside ScrollView
Hi, I got a problem with severe hangs when I use code like this on tvOS 18.2 If I try to use HStack instead of LazyHStack inside the scrollview then the problem does not occur any more but then the scroll performance is compromised and the vertical scroll is no longer that smooth. Does someone has any experience with this? Is this SwiftUI problem or am I missing something? ScrollView { LazyVStack { ForEach(0...100, id: \.self) { _ in ScrollView { LazyHStack { ForEach(0...20, id: \.self) { _ in Color.red.frame(height: 300) } } } } } }
2
0
129
Apr ’25
SwiftUI sheet ignores detent on rapid second presentation
Given a SwiftUI sheet with presentation detent(s): struct ContentView: View { @State var isSheetOpen = false var body: some View { Button("Open Sheet") { isSheetOpen = true } .sheet(isPresented: $isSheetOpen) { Color.black .presentationDetents([.medium]) } } } If you: open the sheet close it and rapidly open it again the second presentation will ignore the detent and open a full screen sheet instead. Xcode 16.3, iOS 18.4 Bug report FB17115890
2
1
92
Apr ’25