Search results for

“swiftui”

17,491 results found

Post

Replies

Boosts

Views

Activity

How to build a picker wheel similar as the Calendar App?
How to build the below UI using SwiftUI? I tried to use Picker with wheel style, but it is not the same as the screenshot. The screenshot came from the iOS built-in calendar app. Add a new calendar event Click Repeat Choose Custom Click Every day The required picker wheel will be displayed Picker(Every, selection: $interval) { ForEach(1..<366) { interval in Text((interval)).tag(interval) } } .pickerStyle(.wheel)
0
0
242
Jun ’26
Xcode 27: Bugs / Feedbacks
Hi, I have listed below the Feedbacks for Xcode 27, please have a look at it, considerable time was spent on filing these feedbacks, thanks! Environments All of them were tested on the environment: macOS 26.5.1 (25F80) Xcode 27.0 beta (27A5194q) Feedbacks FB23133706 (Git stage tab) FB23132869 (markdown - code block) FB23132403 (markdown - search) FB23078039 (stash - slow / unresponsive) FB23077930 (stash - allow multiselection) FB23055381 (Run destination - Clear recents) FB23041713 (SwiftUI preview - SwiftData) FB23033844 (Bundle ID) FB23033231 (Device Hub - sizes)
12
0
1.4k
Jun ’26
How do I get SwiftUI to let me determine a custom frame size for NSTextField
I have a NSViewRepresentable that wraps an NSTextField subclass which is displayed as larger than your typical text field. SwiftUI doesn't seem to allow me to set the size of the view when the underlying is an NSTextField. It forces it as a single line field. I've tried both setting the frame on creation as well as using SwiftUI .frame(width:height:) on the represented view. I always end up with a single line field. struct BigTextField: NSViewRepresentable { @Binding var text: String class Coordinator: NSObject, NSTextFieldDelegate { var parent: BigTextField init(_ parent: BigTextField) { self.parent = parent } func controlTextDidChange(_ obj: Notification) { if let textField = obj.object as? NSTextField { parent.text = textField.stringValue } } } func makeCoordinator() -> Coordinator { Coordinator(self) } func makeNSView(context: Context) -> NSTextField { //let frame = NSRect(x: 0, y: 0, width: 350, height: 140) //let textField = NSTextField(frame: frame) let textField = NSTextField()
0
0
261
Jun ’26
Really happy with Xcode 27 Beta 1 + Claude Agent results
I gave Xcode 27 Beta 1 + Claude Agent my app codebase and set it to work on reviewing the SwiftUI related codebase and suggest improvements in the areas view performance and SwiftUI conformance. I am extremely happy with the results I got. From my experience the Xcode backed Claude Agent is far more versed in SwiftUI related task than pure Claude Code or Claude Code + SwiftUI skill extensions. I was able to visibly increase the performance of several complex views in my app. In addition the Xcode backed agent solved a Liquid Glass related bug with view tinting that I was not able to solve with Claude Code before on its first try. However, in Beta 1 Claude Agent BURNS through tokens at a mind boggling speed. I perceive the agent as a bit to verbose in telling me what it is doing. Allowing the agent to start a simulator and use the app for exploration is setting tokens on fire. I hope that we see refinements in these areas before Xcode 27 is released.
0
0
198
Jun ’26
Reply to How can I reliably refresh WidgetKit widgets across devices after SwiftData + CloudKit synchronization?
I am no expert so take it with a pinch of salt. I don't have a solution when the app is closed. What will not work: ResultsObserver or any of the SwiftUI's @State etc will not work in widgets because this is loaded from a timeline and this is all synchronized to disk, so no way for the widget to react when underlying data changes, that is what makes widgets so efficient. Best I can come up with (it is not ideal): When you open the app observe for core-data sync notifications and reload relevant widgets. Worst case set a timeline refresh policy to a date that is 1 hour from the current time, so that the user has at least the data that is updated 1 hour ago. Summary I don't know how to reload when deviceA updates and deviceB's app is closed If you come up with a solution would love to know
Topic: iCloud SubTopic:
iCloud & CloudKit Q&A
Jun ’26
Reply to Better alternative to WWDC's `withContinuousObservation` in View initializers for SwiftData?
WWDC sample code and code-alongs aren't meant to be architectural endorsements, just quick and easy ways to introduce new stuff in the shortest, most isolated way possible so you can see how the syntax works in a brief video. Your proposed workaround has a couple of key flaws and risks: It will silently fail during CloudKit Sync and database loads. When SwiftData pulls an item from the SQLite database into memory or when CK downloads a remote sync change, it will bypass computed properties entirely, and instead directly populate the underlying stored backing field (_title) using the internal BackingData engine. So if a user modifies an item's title on their iPad, CK will sync that change down to their iPhone. The iPhone will directly apply the update to _title and as a result, because the custom setter for title is completely bypassed updatedAt will never be updated. So now you're dealing with permanent data drift and desync across user devices. It also breaks the context transaction and undo engine. The tran
Jun ’26
Better alternative to WWDC's `withContinuousObservation` in View initializers for SwiftData?
Hi everyone, I was watching the Code-along: Add persistence with SwiftData session and noticed a strange architectural choice at the end. They track model side-effects directly inside a SwiftUI View's initializer like this: init(activity: Activity, isLast: Bool, isEditing: Bool) { activity.token = withContinuousObservation(options: .didSet) { event in // ... side effects here } } This feels like a significant architectural smell. SwiftUI views are transient structures with no guaranteed lifetime—they can be initialized dozens of times a second during standard layout passes. Furthermore, if multiple views display or interact with the same Activity, this tracking work gets duplicated redundantly. I understand this is a workaround because attaching a standard didSet directly to a stored property inside a @Model class doesn't trigger cleanly due to how the macro expands back-end storage. To keep this data-logic in the model layer where it belongs, I came up with an alternative that maps a custom
1
0
851
Jun ’26
Reply to Live activities/dynamic island on macOS
Thanks for the post. This subject is not about Widget and Live Activities, its more about SwiftUI on the macOS, it seems like. In macOS you can achieve a highly comparable user experience by combining a few native macOS paradigms. Since you are building a media application, the goal is to provide a persistent, globally available, and glanceable UI. The closest conceptual equivalent to the Dynamic Island on macOS is a Menu Bar Extra. It is persistently visible, globally accessible regardless of the active application, and supports both a compact and expanded (popover) state. You can dynamically update the label of the MenuBarExtra to show live data just like the compact presentation of the Dynamic Island. Use the .window or .popover style to reveal a rich SwiftUI view when clicked. Keep the menu bar string concise. macOS menu bar space is limited, especially on MacBooks with a physical notch. Do not try to force a literal Dynamic Island UI onto the Mac desktop. Instead, lean into Menu Bar Ext
Topic: Widgets & Live Activities SubTopic:
Widgets & Live Activities Q&A
Jun ’26
UIView wrapper around a View
I couldn't decide whether to post this question here or in SwiftUI Q&A as there's a lot of overlaps. We're trying to create something similar to UIViewRepresentable for UIKit. This might not work for complicated cases where the View has many pieces but as long as it works for simple cases, we're happy. The only problem right now is figuring out the correct height. Currently, the height anchor is assigned to CGFloat.greatestFiniteMagnitude, which works but when inspecting the layout in View Hierarchy, it appears the wrapped view is getting stretched all the way down. Also, sometimes View Hierarchy isn't able to draw the wrapped View and I'm unsure if it's a problem of View Hierarchy or our implementation. final public class SwiftUIConfigurationContainerView: UIView { private var contentView: UIView? public override var intrinsicContentSize: CGSize { contentView?.intrinsicContentSize ?? super.intrinsicContentSize } private var preferredContentSize: CGSize? public init(@ViewBuilder _ content: @escap
0
0
372
Jun ’26
SwiftUI ​Charts: In iOS 27, annotation overlays exceed the bounds of an annotation
I'm seeing a regression in SwiftUI Charts on iOS 27 beta 1. Any view placed inside a BarMark's overlay annotation no longer receives the size of the parent BarMark. It collapses to zero, so any content sized from geo.size (e.g. a Rectangle meant to fill the bar) renders empty or incorrectly. Expected: The GeometryReader reports the BarMark's rendered width/height, and the Rectangle fills the BarMark (this is the behavior in iOS 26 and earlier). Actual: On iOS 27 beta 1, geo.size is effectively zero, so the overlay content has an extremely small size. I suspect this could be a small bug with the new ContentBuilder / ViewBuilder changes but that's just a hunch. Here's a code sample which reproduces the issue. // MARK: - Mock Data Models struct ScheduleSeries: Identifiable { let id = UUID() let data: [ScheduleItem] } struct ScheduleItem: Identifiable { let id = UUID() let startDate: Date let startHour: Double let endHour: Double let secondaryText: String? } // MARK: - Minimal Reproducible Example struct
4
0
682
Jun ’26
[iOS 26] Same app can occupy both minimal Dynamic Island slots simultaneously — expected behavior or bug?
Hi everyone, I'm working on a Live Activity implementation for a ticketing app (written in Swift/SwiftUI with ActivityKit), and I've encountered an unexpected behavior on iOS 26.2.1 that contradicts my understanding of the documentation. What the docs say: The official ActivityKit documentation states: The system uses the minimal presentation when more than one app has an active Live Activity. This implies the two minimal slots are intended for two different apps. There is no documented scenario where a single app occupies both minimal positions simultaneously. What I observed: On a device running iOS 26.2.1, with two active Live Activities from the same app running at the same time, both minimal views appeared on the Dynamic Island simultaneously — one attached to the island, one as a detached floating pill. Questions: Is this behavior intentional in iOS 26, or is it a regression / unintended side effect? Has the system policy changed in iOS 26 to allow a single app to occupy both minimal slots? If
1
0
573
Jun ’26
iOS 27 beta 1: .scrollEdgeEffectStyle(.soft) renders fully transparent above safeAreaBar
Feedback ID: FB23086400 On iOS 27 beta 1, .scrollEdgeEffectStyle(.soft, for: .top) on a List underneath a custom .safeAreaBar(edge: .top) no longer renders the progressive fade-blur. The top edge is fully transparent — scrolled rows pass under the bar with no visual treatment at all, as if scrollEdgeEffectDisabled() had been applied. What I've verified so far: .hard renders correctly in the exact same hierarchy; only .soft is affected. The same binary works correctly on iOS 26.x Xcode preview. I'm building with Xcode 26.3 (iOS 26 SDK). Minimal reproduction: import SwiftUI struct EdgeEffectRepro: View { enum Style: String, CaseIterable, Identifiable { case automatic, soft, hard var id: Self { self } var value: ScrollEdgeEffectStyle { switch self { case .automatic: .automatic case .soft: .soft case .hard: .hard } } } @State private var style: Style = .soft @State private var useSystemBarOnly = false var body: some View { NavigationStack { List(0..<60, id: .self) { i in Text(Row (i)) .frame(maxWidth:
15
0
2.6k
Jun ’26
How to detect backspace in SwiftUI TextField without falling back to UIViewRepresentable?
I'm building a multi-box PIN/OTP input in SwiftUI. In UIKit, I used UITextFieldDelegate to detect backspace presses on an empty field to move focus backward. SwiftUI’s .onChange(of: text) only triggers when text is actually deleted, completely missing backspaces on an already empty field. Is there a pure SwiftUI way to handle this now, or are we still forced to wrap UITextField via UIViewRepresentable?
1
0
245
Jun ’26
Is there a better way to hide a view in a custom Layout other than placing it off-screen?
I have a custom Layout that places a number of labels for a cell footer in a certain way based on the available width that needs to conditionally hide those views that do not entirely fit anymore (based on some priorities I specify). Currently I simply move the subviews that do not fit anymore off-screen and use clipping to hide them outside the layout, as I did not find an official way to hide / exclude a subview from a Layout. Does anyone know a better / nicer way to do this in SwiftUI?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
78
Jun ’26
How to build a picker wheel similar as the Calendar App?
How to build the below UI using SwiftUI? I tried to use Picker with wheel style, but it is not the same as the screenshot. The screenshot came from the iOS built-in calendar app. Add a new calendar event Click Repeat Choose Custom Click Every day The required picker wheel will be displayed Picker(Every, selection: $interval) { ForEach(1..<366) { interval in Text((interval)).tag(interval) } } .pickerStyle(.wheel)
Replies
0
Boosts
0
Views
242
Activity
Jun ’26
Xcode 27: Bugs / Feedbacks
Hi, I have listed below the Feedbacks for Xcode 27, please have a look at it, considerable time was spent on filing these feedbacks, thanks! Environments All of them were tested on the environment: macOS 26.5.1 (25F80) Xcode 27.0 beta (27A5194q) Feedbacks FB23133706 (Git stage tab) FB23132869 (markdown - code block) FB23132403 (markdown - search) FB23078039 (stash - slow / unresponsive) FB23077930 (stash - allow multiselection) FB23055381 (Run destination - Clear recents) FB23041713 (SwiftUI preview - SwiftData) FB23033844 (Bundle ID) FB23033231 (Device Hub - sizes)
Replies
12
Boosts
0
Views
1.4k
Activity
Jun ’26
How do I get SwiftUI to let me determine a custom frame size for NSTextField
I have a NSViewRepresentable that wraps an NSTextField subclass which is displayed as larger than your typical text field. SwiftUI doesn't seem to allow me to set the size of the view when the underlying is an NSTextField. It forces it as a single line field. I've tried both setting the frame on creation as well as using SwiftUI .frame(width:height:) on the represented view. I always end up with a single line field. struct BigTextField: NSViewRepresentable { @Binding var text: String class Coordinator: NSObject, NSTextFieldDelegate { var parent: BigTextField init(_ parent: BigTextField) { self.parent = parent } func controlTextDidChange(_ obj: Notification) { if let textField = obj.object as? NSTextField { parent.text = textField.stringValue } } } func makeCoordinator() -> Coordinator { Coordinator(self) } func makeNSView(context: Context) -> NSTextField { //let frame = NSRect(x: 0, y: 0, width: 350, height: 140) //let textField = NSTextField(frame: frame) let textField = NSTextField()
Replies
0
Boosts
0
Views
261
Activity
Jun ’26
Really happy with Xcode 27 Beta 1 + Claude Agent results
I gave Xcode 27 Beta 1 + Claude Agent my app codebase and set it to work on reviewing the SwiftUI related codebase and suggest improvements in the areas view performance and SwiftUI conformance. I am extremely happy with the results I got. From my experience the Xcode backed Claude Agent is far more versed in SwiftUI related task than pure Claude Code or Claude Code + SwiftUI skill extensions. I was able to visibly increase the performance of several complex views in my app. In addition the Xcode backed agent solved a Liquid Glass related bug with view tinting that I was not able to solve with Claude Code before on its first try. However, in Beta 1 Claude Agent BURNS through tokens at a mind boggling speed. I perceive the agent as a bit to verbose in telling me what it is doing. Allowing the agent to start a simulator and use the app for exploration is setting tokens on fire. I hope that we see refinements in these areas before Xcode 27 is released.
Replies
0
Boosts
0
Views
198
Activity
Jun ’26
Reply to How can I reliably refresh WidgetKit widgets across devices after SwiftData + CloudKit synchronization?
I am no expert so take it with a pinch of salt. I don't have a solution when the app is closed. What will not work: ResultsObserver or any of the SwiftUI's @State etc will not work in widgets because this is loaded from a timeline and this is all synchronized to disk, so no way for the widget to react when underlying data changes, that is what makes widgets so efficient. Best I can come up with (it is not ideal): When you open the app observe for core-data sync notifications and reload relevant widgets. Worst case set a timeline refresh policy to a date that is 1 hour from the current time, so that the user has at least the data that is updated 1 hour ago. Summary I don't know how to reload when deviceA updates and deviceB's app is closed If you come up with a solution would love to know
Topic: iCloud SubTopic:
iCloud & CloudKit Q&A
Replies
Boosts
Views
Activity
Jun ’26
Reply to Better alternative to WWDC's `withContinuousObservation` in View initializers for SwiftData?
WWDC sample code and code-alongs aren't meant to be architectural endorsements, just quick and easy ways to introduce new stuff in the shortest, most isolated way possible so you can see how the syntax works in a brief video. Your proposed workaround has a couple of key flaws and risks: It will silently fail during CloudKit Sync and database loads. When SwiftData pulls an item from the SQLite database into memory or when CK downloads a remote sync change, it will bypass computed properties entirely, and instead directly populate the underlying stored backing field (_title) using the internal BackingData engine. So if a user modifies an item's title on their iPad, CK will sync that change down to their iPhone. The iPhone will directly apply the update to _title and as a result, because the custom setter for title is completely bypassed updatedAt will never be updated. So now you're dealing with permanent data drift and desync across user devices. It also breaks the context transaction and undo engine. The tran
Replies
Boosts
Views
Activity
Jun ’26
Better alternative to WWDC's `withContinuousObservation` in View initializers for SwiftData?
Hi everyone, I was watching the Code-along: Add persistence with SwiftData session and noticed a strange architectural choice at the end. They track model side-effects directly inside a SwiftUI View's initializer like this: init(activity: Activity, isLast: Bool, isEditing: Bool) { activity.token = withContinuousObservation(options: .didSet) { event in // ... side effects here } } This feels like a significant architectural smell. SwiftUI views are transient structures with no guaranteed lifetime—they can be initialized dozens of times a second during standard layout passes. Furthermore, if multiple views display or interact with the same Activity, this tracking work gets duplicated redundantly. I understand this is a workaround because attaching a standard didSet directly to a stored property inside a @Model class doesn't trigger cleanly due to how the macro expands back-end storage. To keep this data-logic in the model layer where it belongs, I came up with an alternative that maps a custom
Replies
1
Boosts
0
Views
851
Activity
Jun ’26
Reply to Live activities/dynamic island on macOS
Thanks for the post. This subject is not about Widget and Live Activities, its more about SwiftUI on the macOS, it seems like. In macOS you can achieve a highly comparable user experience by combining a few native macOS paradigms. Since you are building a media application, the goal is to provide a persistent, globally available, and glanceable UI. The closest conceptual equivalent to the Dynamic Island on macOS is a Menu Bar Extra. It is persistently visible, globally accessible regardless of the active application, and supports both a compact and expanded (popover) state. You can dynamically update the label of the MenuBarExtra to show live data just like the compact presentation of the Dynamic Island. Use the .window or .popover style to reveal a rich SwiftUI view when clicked. Keep the menu bar string concise. macOS menu bar space is limited, especially on MacBooks with a physical notch. Do not try to force a literal Dynamic Island UI onto the Mac desktop. Instead, lean into Menu Bar Ext
Topic: Widgets & Live Activities SubTopic:
Widgets & Live Activities Q&A
Replies
Boosts
Views
Activity
Jun ’26
Dynamic Property inplace of onChange, task.
In the recent SwiftUI Group Lab, they mentioned using Dynamic Property instead of onChange, How to do it? Could it used as an actual property type instead of just using in combination with @propertyWrapper
Replies
0
Boosts
0
Views
204
Activity
Jun ’26
UIView wrapper around a View
I couldn't decide whether to post this question here or in SwiftUI Q&A as there's a lot of overlaps. We're trying to create something similar to UIViewRepresentable for UIKit. This might not work for complicated cases where the View has many pieces but as long as it works for simple cases, we're happy. The only problem right now is figuring out the correct height. Currently, the height anchor is assigned to CGFloat.greatestFiniteMagnitude, which works but when inspecting the layout in View Hierarchy, it appears the wrapped view is getting stretched all the way down. Also, sometimes View Hierarchy isn't able to draw the wrapped View and I'm unsure if it's a problem of View Hierarchy or our implementation. final public class SwiftUIConfigurationContainerView: UIView { private var contentView: UIView? public override var intrinsicContentSize: CGSize { contentView?.intrinsicContentSize ?? super.intrinsicContentSize } private var preferredContentSize: CGSize? public init(@ViewBuilder _ content: @escap
Replies
0
Boosts
0
Views
372
Activity
Jun ’26
SwiftUI ​Charts: In iOS 27, annotation overlays exceed the bounds of an annotation
I'm seeing a regression in SwiftUI Charts on iOS 27 beta 1. Any view placed inside a BarMark's overlay annotation no longer receives the size of the parent BarMark. It collapses to zero, so any content sized from geo.size (e.g. a Rectangle meant to fill the bar) renders empty or incorrectly. Expected: The GeometryReader reports the BarMark's rendered width/height, and the Rectangle fills the BarMark (this is the behavior in iOS 26 and earlier). Actual: On iOS 27 beta 1, geo.size is effectively zero, so the overlay content has an extremely small size. I suspect this could be a small bug with the new ContentBuilder / ViewBuilder changes but that's just a hunch. Here's a code sample which reproduces the issue. // MARK: - Mock Data Models struct ScheduleSeries: Identifiable { let id = UUID() let data: [ScheduleItem] } struct ScheduleItem: Identifiable { let id = UUID() let startDate: Date let startHour: Double let endHour: Double let secondaryText: String? } // MARK: - Minimal Reproducible Example struct
Replies
4
Boosts
0
Views
682
Activity
Jun ’26
[iOS 26] Same app can occupy both minimal Dynamic Island slots simultaneously — expected behavior or bug?
Hi everyone, I'm working on a Live Activity implementation for a ticketing app (written in Swift/SwiftUI with ActivityKit), and I've encountered an unexpected behavior on iOS 26.2.1 that contradicts my understanding of the documentation. What the docs say: The official ActivityKit documentation states: The system uses the minimal presentation when more than one app has an active Live Activity. This implies the two minimal slots are intended for two different apps. There is no documented scenario where a single app occupies both minimal positions simultaneously. What I observed: On a device running iOS 26.2.1, with two active Live Activities from the same app running at the same time, both minimal views appeared on the Dynamic Island simultaneously — one attached to the island, one as a detached floating pill. Questions: Is this behavior intentional in iOS 26, or is it a regression / unintended side effect? Has the system policy changed in iOS 26 to allow a single app to occupy both minimal slots? If
Replies
1
Boosts
0
Views
573
Activity
Jun ’26
iOS 27 beta 1: .scrollEdgeEffectStyle(.soft) renders fully transparent above safeAreaBar
Feedback ID: FB23086400 On iOS 27 beta 1, .scrollEdgeEffectStyle(.soft, for: .top) on a List underneath a custom .safeAreaBar(edge: .top) no longer renders the progressive fade-blur. The top edge is fully transparent — scrolled rows pass under the bar with no visual treatment at all, as if scrollEdgeEffectDisabled() had been applied. What I've verified so far: .hard renders correctly in the exact same hierarchy; only .soft is affected. The same binary works correctly on iOS 26.x Xcode preview. I'm building with Xcode 26.3 (iOS 26 SDK). Minimal reproduction: import SwiftUI struct EdgeEffectRepro: View { enum Style: String, CaseIterable, Identifiable { case automatic, soft, hard var id: Self { self } var value: ScrollEdgeEffectStyle { switch self { case .automatic: .automatic case .soft: .soft case .hard: .hard } } } @State private var style: Style = .soft @State private var useSystemBarOnly = false var body: some View { NavigationStack { List(0..<60, id: .self) { i in Text(Row (i)) .frame(maxWidth:
Replies
15
Boosts
0
Views
2.6k
Activity
Jun ’26
How to detect backspace in SwiftUI TextField without falling back to UIViewRepresentable?
I'm building a multi-box PIN/OTP input in SwiftUI. In UIKit, I used UITextFieldDelegate to detect backspace presses on an empty field to move focus backward. SwiftUI’s .onChange(of: text) only triggers when text is actually deleted, completely missing backspaces on an already empty field. Is there a pure SwiftUI way to handle this now, or are we still forced to wrap UITextField via UIViewRepresentable?
Replies
1
Boosts
0
Views
245
Activity
Jun ’26
Is there a better way to hide a view in a custom Layout other than placing it off-screen?
I have a custom Layout that places a number of labels for a cell footer in a certain way based on the available width that needs to conditionally hide those views that do not entirely fit anymore (based on some priorities I specify). Currently I simply move the subviews that do not fit anymore off-screen and use clipping to hide them outside the layout, as I did not find an official way to hide / exclude a subview from a Layout. Does anyone know a better / nicer way to do this in SwiftUI?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
78
Activity
Jun ’26