Search results for

“swiftui”

17,235 results found

Post

Replies

Boosts

Views

Activity

How to animate `UIHostingController.view` frame when my View's size changes?
I have a UIHostingController on which I have set: hostingController.sizingOptions = [.intrinsicContentSize] The size of my SwiftUI content changes with animation (I update a @Published property on an ObservableObject inside a withAnimation block). However, I notice that my hostingController.view just jumps to the new frame without animating the change. Question: how can I animate the frame changes in UIHostingController that are caused by sizingOptions = [.intrinsicContentSize]
6
0
334
Jan ’26
Accessible Speech Practice App - R Helper Launch
Hi Community, I'm excited to share R Helper, a speech practice app I built with accessibility as the core focus from day one. App Store: https://apps.apple.com/app/speak-r-clearly/id6751442522 WHY I BUILT THIS I personally struggled with R sound pronunciation growing up. It affected my confidence in school and job interviews. That experience taught me how important accessible practice tools are. R Helper helps children and adults practice R sounds with full accessibility support. ACCESSIBILITY FEATURES IMPLEMENTED VoiceOver - complete navigation and feedback Voice Control - hands-free operation Dynamic Type - scales to large accessibility sizes Reduce Motion - respects user preference Dark Mode - user controllable High Contrast compatibility Differentiate Without Color THE CHALLENGE Most speech practice apps ignore accessibility. I wanted to change that and prove that specialized educational apps can be fully accessible. KEY FEATURES Works 100% offline, no internet needed Zero data collection, privacy first G
2
0
1.9k
Jan ’26
Reply to AppKit - Legal to Change a View's Frame in -viewDidLayout?
Thanks for the post, it’s hard not seeing the code and how you're setting constrains in code. Would you be so kind to provide your code where you setting the constraints so developers here can see it? What do you mean by legal? it is generally not a good idea (and will lead to crashes) to directly modify the frame or bounds of a view that is managed by Auto Layout in my opinion. In my experience any method that directly or indirectly causes setNeedsLayout() or setNeedsDisplay() or changes the frame or bounds of a view that is managed by Auto Layout, may likely trigger the same infinite loop and exception. I think AppKit's layout cycle (especially with Auto Layout) translatesAutoresizingMaskIntoConstraints creates weird fixed width and height constraints leading to Unable to simultaneously satisfy constraints warnings isn’t? When you then add a view add an explicit Auto Layout constraints to a view hierarchy where translatesAutoresizingMaskIntoConstraints is true for some views, you often end up with conflicti
Topic: UI Frameworks SubTopic: AppKit Tags:
Jan ’26
SwiftUI TextEditor: replaced text jumps outside current selection
I have a text editor where I replace the selected text when a button is tapped. Most of the time it works, but sometimes the new text is inserted at the end of the text instead of at the selected position. Is this a bug? @Bindable var note: Richnote @State private var selection = AttributedTextSelection() var body: some View { VStack { TextEditor(text: $note.content, selection: $selection) Button(Replace text) { let textToInsert = A long text that makes me think lalala note.content.replaceSelection(&selection, withCharacters: textToInsert) }
Topic: UI Frameworks SubTopic: SwiftUI
2
0
76
Jan ’26
Why MapKit Is So Unpredictable for macOS?
I have an existing iOS app with MapKit. It always shows the current user location with UserAnnotation. But the same isn't true for macOS. I have this sample macOS application in SwiftUI. In the following, the current user location with a large blue dot appears only occasionally. It won't, 19 of 20 times. Why is that? I do have a location privacy key in Info.plist. And the Location checkbox is on under Signing & Capabilities. import SwiftUI import MapKit struct ContentView: View { @State private var markerItems: [MarkerItem] = [ MarkerItem(name: Farmers Market 1, lat: 35.681, lon: 139.691), MarkerItem(name: Farmers Market 2, lat: 35.685, lon: 139.695), MarkerItem(name: Farmers Market 3, lat: 35.689, lon: 139.699) ] @State private var position: MapCameraPosition = .automatic var body: some View { Map(position: $position) { UserAnnotation() ForEach(markerItems, id: .self) { item in Marker(item.name, coordinate: CLLocationCoordinate2D(latitude: item.lat, longitude: item.lon)) } } .mapControl
0
0
103
Jan ’26
Tabview page dots like in the weather app
Hi, I am looking to display (in SwiftUI) the Tabview page dots like in the weather app in the toolbar, an important thing is I want to keep page controls by tapping and scrubbing. Actually, I want to do what's on Apple Design's Page Controls page; here's the link and a photo of what I'd like to do. Could you help me? https://developer.apple.com/design/human-interface-guidelines/page-controls
1
0
95
Jan ’26
tabViewBottomAccessory causes unstable view identity for views accessing Environment or State
Views placed inside tabViewBottomAccessory that access @Environment values or contain @State properties experience unstable identity, as shown by Self._printChanges(). The identity changes on every structural update to the TabView, even though the view's actual identity should remain stable. This causes unnecessary view recreation and breaks SwiftUI's expected identity and lifecycle behavior. Environment Xcode Version 26.2 (17C52) iOS 26.2 simulator and device struct ContentView: View { @State var showMoreTabs = true struct DemoTab: View { var body: some View { Text(String(describing: type(of: self))) } } var body: some View { TabView { Tab(Home, systemImage: house) { DemoTab() } Tab(Alerts, systemImage: bell) { DemoTab() } if showMoreTabs { TabSection(Categories) { Tab(Climate, systemImage: fan) { DemoTab() } Tab(Lights, systemImage: lightbulb) { DemoTab() } } } Tab(Settings, systemImage: gear) { List { Toggle(Show more Tabs, isOn: $showMoreTabs) } } } .tabViewBottomAccessory { AccessoryView() } .ta
0
0
72
Jan ’26
`ImageRenderer.render` halts program with `EXC_BREAKPOINT` inside SwiftUI/AttributeGraph
This extension View { public func renderSomething() async throws { let renderer = ImageRenderer(content: self) // renderer.colorMode = .linear renderer.render { size, context in print(size) // ... } // ... } } let view: some View = ... view.renderSomething() // → exception will cause the program to exit with EXC_BREAKPOINT deep inside SwiftUI. This worked with previous versions of Xcode, SwiftUI, and macOS. Xcode Version 26.2 (17C52), macOS Sequoia 15.7.3, using toolchain bundled with Xcode.
0
0
54
Jan ’26
Cannot overwrite Swift package default traits in Xcode
I am using swift-subprocess, and need to disable the SubprocessSpan trait because Xcode 26.2 does not ship with a bundled version libswiftCompatibilitySpan.dylib, causing everything to crash built with Xcode that happens to use Span. However, I cannot disable that trait by doing any of the following things: .package( url: https://github.com/swiftlang/swift-subprocess.git, branch: main, traits: [] ), .package( url: https://github.com/swiftlang/swift-subprocess.git, branch: main, traits: [.trait(name: SubprocessFoundation)] ), Note that SubprocessSpan is default trait in subprocess: // Enable SubprocessFoundation by default var defaultTraits: Set = [SubprocessFoundation] #if compiler(>=6.2) // Enable SubprocessSpan when Span is available [except it is not] defaultTraits.insert(SubprocessSpan) #endif The package still builds with the SubprocessSpan enabled. This is not an issue with the subprocess package. According to this, I should use swift build on the command line, yet this isn't -- as is upgrading to Ta
0
0
118
Jan ’26
SwiftUI Instruments Template doesn't work
I am profiling a simple SwiftUI test app on my new iPhone through my new MacBook Pro and everything is version 26.2 (iOS, macOS, Xcode). I run Instruments with the SwiftUI template using all of the default settings and get absolutely zero data after interacting with the app for about 20 seconds. Using the Time Profiler template yields trace data. Trying the SwiftUI template again with the sample Landmarks app has the same issue as my app.
2
0
558
Jan ’26
Reply to AVCaptureSession preview briefly goes blank after interruption (lock/unlock or camera switch) while isRunning == true
Update / Resolution In my case, the flashing preview was not a capture pipeline issue, but a SwiftUI view lifecycle issue. The camera preview was conditionally shown using: authorized && session.isRunning && cameraReady During lock/unlock or camera switches, SwiftUI re-evaluates this condition multiple times. AVCaptureSession.isRunning can briefly fluctuate during interruption recovery, causing SwiftUI to: remove the preview view show a placeholder immediately reinsert the preview This rapid view swapping appeared as a “blank flash”. The preview layer itself was fine. Fix I removed session.isRunning from the SwiftUI visibility condition. The logic is now: authorized && cameraReady cameraReady is set once after initial setup and never toggles during interruptions. The preview view stays mounted at all times. Why this works AVCaptureVideoPreviewLayer already handles short “no frames” periods gracefully. By keeping the preview layer mounted and avoiding
Jan ’26
Reply to Crash in swift::_getWitnessTable when passing UITraitBridgedEnvironmentKey
FB20843042 is the feedback we filed which includes a sample project. What is the intent of foo(key: MyCustomTraitKey.self)? It was added in an effort to identify the source of the crash by minimizing types and functions used from system SDKs. The issue occurs with any function with the same signature. The original ossie wsa found when calling https://developer.apple.com/documentation/swiftui/environmentvalues/subscript(_:)-9zku
Topic: UI Frameworks SubTopic: UIKit Tags:
Jan ’26
Reply to app bar menu items flickering swiftUI app development my ios26.2
Thank you for your post. I am attempting to understand what you are tying to accomplish. Because you are using the UIHostingController I guess you are using UIKit and SwiftUI together? It would be greatly appreciated if you could provide a focused sample to demo the issue, without code is really hard for me. In my opinion I believe this error message suggests that you are attempting to directly add a subview to the view hierarchy of a view controller, which is not suggested and can result in issues with the view hierarchy. A view controller is designed to manage its own view hierarchy, and directly tampering with it can lead to unexpected behavior. If you wish to overlay or add views around the SwiftUI content managed by a view controller, you should do so by adding your views to a common superview that contains the view controller’s view. If your objective is to integrate UIKit views into SwiftUI, consider using to encapsulate a UIKit view and incorporate it within your SwiftUI
Topic: UI Frameworks SubTopic: SwiftUI
Jan ’26
How to animate `UIHostingController.view` frame when my View's size changes?
I have a UIHostingController on which I have set: hostingController.sizingOptions = [.intrinsicContentSize] The size of my SwiftUI content changes with animation (I update a @Published property on an ObservableObject inside a withAnimation block). However, I notice that my hostingController.view just jumps to the new frame without animating the change. Question: how can I animate the frame changes in UIHostingController that are caused by sizingOptions = [.intrinsicContentSize]
Replies
6
Boosts
0
Views
334
Activity
Jan ’26
Accessible Speech Practice App - R Helper Launch
Hi Community, I'm excited to share R Helper, a speech practice app I built with accessibility as the core focus from day one. App Store: https://apps.apple.com/app/speak-r-clearly/id6751442522 WHY I BUILT THIS I personally struggled with R sound pronunciation growing up. It affected my confidence in school and job interviews. That experience taught me how important accessible practice tools are. R Helper helps children and adults practice R sounds with full accessibility support. ACCESSIBILITY FEATURES IMPLEMENTED VoiceOver - complete navigation and feedback Voice Control - hands-free operation Dynamic Type - scales to large accessibility sizes Reduce Motion - respects user preference Dark Mode - user controllable High Contrast compatibility Differentiate Without Color THE CHALLENGE Most speech practice apps ignore accessibility. I wanted to change that and prove that specialized educational apps can be fully accessible. KEY FEATURES Works 100% offline, no internet needed Zero data collection, privacy first G
Replies
2
Boosts
0
Views
1.9k
Activity
Jan ’26
Reply to SwiftUI TextEditor: replaced text jumps outside current selection
Hi Albert, thank you for replying. Here is my Richnote class: import SwiftUI import SwiftData @Model final class Richnote { @Attribute(.externalStorage) var content : AttributedString var createdAt: Date = Date() init(content: AttributedString) { self.content = content } }
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jan ’26
Reply to AppKit - Legal to Change a View's Frame in -viewDidLayout?
Thanks for the post, it’s hard not seeing the code and how you're setting constrains in code. Would you be so kind to provide your code where you setting the constraints so developers here can see it? What do you mean by legal? it is generally not a good idea (and will lead to crashes) to directly modify the frame or bounds of a view that is managed by Auto Layout in my opinion. In my experience any method that directly or indirectly causes setNeedsLayout() or setNeedsDisplay() or changes the frame or bounds of a view that is managed by Auto Layout, may likely trigger the same infinite loop and exception. I think AppKit's layout cycle (especially with Auto Layout) translatesAutoresizingMaskIntoConstraints creates weird fixed width and height constraints leading to Unable to simultaneously satisfy constraints warnings isn’t? When you then add a view add an explicit Auto Layout constraints to a view hierarchy where translatesAutoresizingMaskIntoConstraints is true for some views, you often end up with conflicti
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Jan ’26
SwiftUI TextEditor: replaced text jumps outside current selection
I have a text editor where I replace the selected text when a button is tapped. Most of the time it works, but sometimes the new text is inserted at the end of the text instead of at the selected position. Is this a bug? @Bindable var note: Richnote @State private var selection = AttributedTextSelection() var body: some View { VStack { TextEditor(text: $note.content, selection: $selection) Button(Replace text) { let textToInsert = A long text that makes me think lalala note.content.replaceSelection(&selection, withCharacters: textToInsert) }
Topic: UI Frameworks SubTopic: SwiftUI
Replies
2
Boosts
0
Views
76
Activity
Jan ’26
Why MapKit Is So Unpredictable for macOS?
I have an existing iOS app with MapKit. It always shows the current user location with UserAnnotation. But the same isn't true for macOS. I have this sample macOS application in SwiftUI. In the following, the current user location with a large blue dot appears only occasionally. It won't, 19 of 20 times. Why is that? I do have a location privacy key in Info.plist. And the Location checkbox is on under Signing & Capabilities. import SwiftUI import MapKit struct ContentView: View { @State private var markerItems: [MarkerItem] = [ MarkerItem(name: Farmers Market 1, lat: 35.681, lon: 139.691), MarkerItem(name: Farmers Market 2, lat: 35.685, lon: 139.695), MarkerItem(name: Farmers Market 3, lat: 35.689, lon: 139.699) ] @State private var position: MapCameraPosition = .automatic var body: some View { Map(position: $position) { UserAnnotation() ForEach(markerItems, id: .self) { item in Marker(item.name, coordinate: CLLocationCoordinate2D(latitude: item.lat, longitude: item.lon)) } } .mapControl
Replies
0
Boosts
0
Views
103
Activity
Jan ’26
Reply to “Keep Going with Apps” Tutorial section will not complete.
I'm also running into this issue, it's very annoying because I'm trying to learn swiftui to build an app. I submitted a bug report right before commenting & boosting so hopefully this gets fixed sooner rather than later!
Replies
Boosts
Views
Activity
Jan ’26
Tabview page dots like in the weather app
Hi, I am looking to display (in SwiftUI) the Tabview page dots like in the weather app in the toolbar, an important thing is I want to keep page controls by tapping and scrubbing. Actually, I want to do what's on Apple Design's Page Controls page; here's the link and a photo of what I'd like to do. Could you help me? https://developer.apple.com/design/human-interface-guidelines/page-controls
Replies
1
Boosts
0
Views
95
Activity
Jan ’26
tabViewBottomAccessory causes unstable view identity for views accessing Environment or State
Views placed inside tabViewBottomAccessory that access @Environment values or contain @State properties experience unstable identity, as shown by Self._printChanges(). The identity changes on every structural update to the TabView, even though the view's actual identity should remain stable. This causes unnecessary view recreation and breaks SwiftUI's expected identity and lifecycle behavior. Environment Xcode Version 26.2 (17C52) iOS 26.2 simulator and device struct ContentView: View { @State var showMoreTabs = true struct DemoTab: View { var body: some View { Text(String(describing: type(of: self))) } } var body: some View { TabView { Tab(Home, systemImage: house) { DemoTab() } Tab(Alerts, systemImage: bell) { DemoTab() } if showMoreTabs { TabSection(Categories) { Tab(Climate, systemImage: fan) { DemoTab() } Tab(Lights, systemImage: lightbulb) { DemoTab() } } } Tab(Settings, systemImage: gear) { List { Toggle(Show more Tabs, isOn: $showMoreTabs) } } } .tabViewBottomAccessory { AccessoryView() } .ta
Replies
0
Boosts
0
Views
72
Activity
Jan ’26
`ImageRenderer.render` halts program with `EXC_BREAKPOINT` inside SwiftUI/AttributeGraph
This extension View { public func renderSomething() async throws { let renderer = ImageRenderer(content: self) // renderer.colorMode = .linear renderer.render { size, context in print(size) // ... } // ... } } let view: some View = ... view.renderSomething() // → exception will cause the program to exit with EXC_BREAKPOINT deep inside SwiftUI. This worked with previous versions of Xcode, SwiftUI, and macOS. Xcode Version 26.2 (17C52), macOS Sequoia 15.7.3, using toolchain bundled with Xcode.
Replies
0
Boosts
0
Views
54
Activity
Jan ’26
Cannot overwrite Swift package default traits in Xcode
I am using swift-subprocess, and need to disable the SubprocessSpan trait because Xcode 26.2 does not ship with a bundled version libswiftCompatibilitySpan.dylib, causing everything to crash built with Xcode that happens to use Span. However, I cannot disable that trait by doing any of the following things: .package( url: https://github.com/swiftlang/swift-subprocess.git, branch: main, traits: [] ), .package( url: https://github.com/swiftlang/swift-subprocess.git, branch: main, traits: [.trait(name: SubprocessFoundation)] ), Note that SubprocessSpan is default trait in subprocess: // Enable SubprocessFoundation by default var defaultTraits: Set = [SubprocessFoundation] #if compiler(>=6.2) // Enable SubprocessSpan when Span is available [except it is not] defaultTraits.insert(SubprocessSpan) #endif The package still builds with the SubprocessSpan enabled. This is not an issue with the subprocess package. According to this, I should use swift build on the command line, yet this isn't -- as is upgrading to Ta
Replies
0
Boosts
0
Views
118
Activity
Jan ’26
SwiftUI Instruments Template doesn't work
I am profiling a simple SwiftUI test app on my new iPhone through my new MacBook Pro and everything is version 26.2 (iOS, macOS, Xcode). I run Instruments with the SwiftUI template using all of the default settings and get absolutely zero data after interacting with the app for about 20 seconds. Using the Time Profiler template yields trace data. Trying the SwiftUI template again with the sample Landmarks app has the same issue as my app.
Replies
2
Boosts
0
Views
558
Activity
Jan ’26
Reply to AVCaptureSession preview briefly goes blank after interruption (lock/unlock or camera switch) while isRunning == true
Update / Resolution In my case, the flashing preview was not a capture pipeline issue, but a SwiftUI view lifecycle issue. The camera preview was conditionally shown using: authorized && session.isRunning && cameraReady During lock/unlock or camera switches, SwiftUI re-evaluates this condition multiple times. AVCaptureSession.isRunning can briefly fluctuate during interruption recovery, causing SwiftUI to: remove the preview view show a placeholder immediately reinsert the preview This rapid view swapping appeared as a “blank flash”. The preview layer itself was fine. Fix I removed session.isRunning from the SwiftUI visibility condition. The logic is now: authorized && cameraReady cameraReady is set once after initial setup and never toggles during interruptions. The preview view stays mounted at all times. Why this works AVCaptureVideoPreviewLayer already handles short “no frames” periods gracefully. By keeping the preview layer mounted and avoiding
Replies
Boosts
Views
Activity
Jan ’26
Reply to Crash in swift::_getWitnessTable when passing UITraitBridgedEnvironmentKey
FB20843042 is the feedback we filed which includes a sample project. What is the intent of foo(key: MyCustomTraitKey.self)? It was added in an effort to identify the source of the crash by minimizing types and functions used from system SDKs. The issue occurs with any function with the same signature. The original ossie wsa found when calling https://developer.apple.com/documentation/swiftui/environmentvalues/subscript(_:)-9zku
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jan ’26
Reply to app bar menu items flickering swiftUI app development my ios26.2
Thank you for your post. I am attempting to understand what you are tying to accomplish. Because you are using the UIHostingController I guess you are using UIKit and SwiftUI together? It would be greatly appreciated if you could provide a focused sample to demo the issue, without code is really hard for me. In my opinion I believe this error message suggests that you are attempting to directly add a subview to the view hierarchy of a view controller, which is not suggested and can result in issues with the view hierarchy. A view controller is designed to manage its own view hierarchy, and directly tampering with it can lead to unexpected behavior. If you wish to overlay or add views around the SwiftUI content managed by a view controller, you should do so by adding your views to a common superview that contains the view controller’s view. If your objective is to integrate UIKit views into SwiftUI, consider using to encapsulate a UIKit view and incorporate it within your SwiftUI
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jan ’26