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

iOS 26: Toolbar button background flashes black during NavigationStack transitions (dark mode)
I’m seeing a visual glitch with toolbar buttons when building with Xcode 26 for iOS 26. During transitions (both pushing in a NavigationStack and presenting a .sheet with its own NavigationStack), the toolbar button briefly flashes the wrong background colour (black in dark mode, white in light mode) before animating to the correct Liquid Glass appearance. This happens even in a minimal example and only seems to affect system toolbar buttons. A custom view with .glassEffect() doesn’t have the issue. I’ve tried: .tint(...), UINavigationBarAppearance/UIToolbarAppearance, and setting backgrounds on hosting/nav/window but none of those made any difference. Here’s a minimal reproducible example: import SwiftUI struct ContentView: View { @State private var showingSheet = false var body: some View { NavigationStack { List { NavigationLink("Push (same stack — morphs)") { DetailView() } Button("Sheet (separate stack — flashes)") { showingSheet = true } } .navigationTitle("Root") .scrollContentBackground(.hidden) .background(.gray) .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Action") {} } } .sheet(isPresented: $showingSheet) { SheetView() } } } } struct DetailView: View { var body: some View { Text("Detail (same stack)") .frame(maxWidth: .infinity, maxHeight: .infinity) .background(.gray) .navigationTitle("Detail") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Action") {} } } } } struct SheetView: View { var body: some View { NavigationStack { Text("Sheet (separate stack)") .frame(maxWidth: .infinity, maxHeight: .infinity) .background(.gray) .navigationTitle("Sheet") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Action") {} } } } } } Has anyone else seen this or found a workaround outside of disabling this background completely with .sharedBackgroundVisibility(.hidden)? I have filed a bug report under FB22141183
0
0
38
6h
Glass Effect Label Shadow Clipping During Morph Animation
Hi all, I’m experiencing a visual bug when applying the glass effect to a Label in Liquid Glass (current version 26.2 on simulator; also reproducible in 26.3.1 on device). Issue: On a label with .glassEffect(.regular), when collapsing via morph animation, the shadow is clipped during the animation, and then suddenly "pops" back to its un-clipped state, resulting in a jarring visual effect. Minimal Example: import SwiftUI struct ContentView: View { var body: some View { Menu { Button("Duplicate", action: {}) Button("Rename", action: {}) Button("Delete…", action: {}) } label: { Label("PDF", systemImage: "doc.fill") .padding() .glassEffect(.regular) } } } #Preview { ContentView() } I am not sure if I am misusing the .glassEffect() on the label and maybe there is another more native way of achieving this look? Any advice or workaround suggestions would be greatly appreciated!
2
0
56
1d
Back gesture not disabled with navigationBarBackButtonHidden(true) when using .zoom transition
[Submitted as FB22226720] For a NavigationStack destination, applying .navigationBarBackButtonHidden(true) hides the back button and also disables the interactive left-edge back gesture when using the standard push navigation transition. However, when the destination uses .navigationTransition(.zoom), the back button is hidden but the left-edge back gesture is still available—it can still be dismissed even though back is intentionally suppressed. This creates inconsistent behavior between navigation transition styles. navigationBarBackButtonHidden(_:) works with a standard push transition, but not with .navigationTransition(.zoom). In the code below, .interactiveDismissDisabled(true) is also applied as another attempt to suppress the back-swipe gesture, but it has no effect. As a result, there’s currently no clean way to prevent back navigation when using the zoom transition. REPRO STEPS Create an iOS project then replace ContentView with code below, build and run. Leave nav type set to List Push. Open an item. Verify there is no back button, then try the left-edge back gesture. Return to the root view. Change nav type to Grid Zoom. Open an item. Verify there is no back button, then try the left-edge back gesture. ACTUAL In List Push mode, the left-edge back gesture is prevented. In Grid Zoom mode, the back button is hidden, but the left-edge back gesture still works and returns to the previous view. EXPECTED Behavior should be consistent across navigation transition styles. If this configuration is meant to suppress interactive backward navigation for a destination, it should also suppress the left-edge back gesture when using .navigationTransition(.zoom). SCREEN RECORDING SAMPLE CODE struct ContentView: View { private enum NavigationMode: String, CaseIterable { case listPush = "List Push" case gridZoom = "Grid Zoom" } @Namespace private var namespace @State private var navigationMode: NavigationMode = .listPush private let colors: [Color] = [.red, .blue] var body: some View { NavigationStack { VStack(spacing: 16) { Picker("Navigation Type", selection: $navigationMode) { ForEach(NavigationMode.allCases, id: \.self) { mode in Text(mode.rawValue).tag(mode) } } .pickerStyle(.segmented) if navigationMode == .gridZoom { HStack { ForEach(colors.indices, id: \.self) { index in NavigationLink(value: index) { VStack { RoundedRectangle(cornerRadius: 14) .fill(colors[index]) .frame(height: 120) Text("Grid Item \(index + 1)") .font(.subheadline.weight(.medium)) } .padding(12) .frame(maxWidth: .infinity) .background(.quaternary.opacity(0.25), in: RoundedRectangle(cornerRadius: 16)) .matchedTransitionSource(id: index, in: namespace) } .buttonStyle(.plain) } } } else { ForEach(colors.indices, id: \.self) { index in NavigationLink(value: index) { HStack { Circle() .fill(colors[index]) .frame(width: 24, height: 24) Text("List Item \(index + 1)") Spacer() Image(systemName: "chevron.right") .foregroundStyle(.secondary) } .padding() .background(.quaternary.opacity(0.25), in: RoundedRectangle(cornerRadius: 12)) } .buttonStyle(.plain) } } Spacer() } .padding(20) .navigationTitle("Prevent Back Swipe") .navigationSubtitle("Compare Grid Zoom vs List Push") .navigationDestination(for: Int.self) { index in if navigationMode == .gridZoom { DetailView(color: colors[index]) .navigationTransition(.zoom(sourceID: index, in: namespace)) } else { DetailView(color: colors[index]) } } } } } private struct DetailView: View { @Environment(\.dismiss) private var dismiss let color: Color var body: some View { ZStack { color.ignoresSafeArea() Text("Try left-edge swipe back") .font(.title.bold()) .multilineTextAlignment(.center) .padding(.horizontal, 24) } .navigationBarBackButtonHidden(true) .interactiveDismissDisabled(true) .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Close", action: dismiss.callAsFunction) } } } }
2
0
556
1d
hapticpatternlibrary.plist error with Text entry fields in Simulator only
When I have a TextField or TextEditor, tapping into it produces these two console entries about 18 times each: CHHapticPattern.mm:487 +[CHHapticPattern patternForKey:error:]: Failed to read pattern library data: Error Domain=NSCocoaErrorDomain Code=260 "The file “hapticpatternlibrary.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, NSURL=file:///Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, NSUnderlyingError=0x600000ca1b30 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} <_UIKBFeedbackGenerator: 0x600003505290>: Error creating CHHapticPattern: Error Domain=NSCocoaErrorDomain Code=260 "The file “hapticpatternlibrary.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, NSURL=file:///Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, NSUnderlyingError=0x600000ca1b30 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} My app does not use haptics. This doesn't appear to cause any issues, although entering text can feel a bit sluggish (even on device), but I am unable to determine relatedness. None-the-less, it definitely is a lot of log noise. Code to reproduce in simulator (xcode 26.2; ios 26 or 18, with iPhone 16 Pro or iPhone 17 Pro): import SwiftUI struct ContentView: View { @State private var textEntered: String = "" @State private var textEntered2: String = "" @State private var textEntered3: String = "" var body: some View { VStack { Spacer() TextField("Tap Here", text: $textEntered) TextField("Tap Here Too", text: $textEntered2) TextEditor(text: $textEntered3) .overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(.primary, lineWidth: 1)) .frame(height: 100) Spacer() } } } #Preview { ContentView() } Tapping back and forth in these fields generates the errors each time. Thanks, Steve
4
0
647
1d
PhaseAnimator doesn't reflect @Observable state changes after animation settles
I ran into a behavior with PhaseAnimator that I'm not sure is a bug or by design. I'd appreciate any insight. The Problem When an @Observable property is read only inside a PhaseAnimator content closure, changes to that property are ignored after the animation cycle completes and reaches its resting state. The UI gets stuck showing stale data. Minimal Reproduction I've put together a simple demo with two views side by side, both driven by the same ViewModel and toggled by the same button: BrokenView — receives an @Observable object and reads its property inside PhaseAnimator. After the animation completes, toggling the property has no visible effect. FixedView — receives the same value as a Bool parameter. Updates correctly every time because view's parameter has changed. import SwiftUI @Observable class ViewModel { var isError = false } struct BrokenView: View { let viewModel: ViewModel @State private var trigger = false var body: some View { VStack(spacing: 20) { Text("Broken (@Observable)").font(.headline) PhaseAnimator([false, true], trigger: trigger) { _ in if viewModel.isError { Text("Error!").foregroundStyle(.red).font(.largeTitle) } else { Text("OK").foregroundStyle(.green).font(.largeTitle) } } } .padding() .onAppear { trigger = true } } } struct FixedView: View { let isError: Bool @State private var trigger = false var body: some View { VStack(spacing: 20) { Text("Fixed (Value Type)").font(.headline) PhaseAnimator([false, true], trigger: trigger) { _ in if isError { Text("Error!").foregroundStyle(.red).font(.largeTitle) } else { Text("OK").foregroundStyle(.green).font(.largeTitle) } } } .padding() .onAppear { trigger = true } } } struct DemoView: View { @State private var viewModel = ViewModel() var body: some View { VStack(spacing: 40) { BrokenView(viewModel: viewModel) Divider() FixedView(isError: viewModel.isError) Divider() Button("Toggle isError: \(viewModel.isError)") { viewModel.isError.toggle() } .buttonStyle(.borderedProminent) } .padding() } } Run the preview, then tap the toggle button. FixedView updates instantly; BrokenView stays stuck. My Understanding It seems like PhaseAnimator only tracks @Observable access during active animation phases. Once it settles at rest, the content closure is not re-evaluated, so observation tracking is effectively lost. Passing a value type works because SwiftUI view diffing detects the input change and triggers a body re-evaluation, which in turn re-evaluates the PhaseAnimator content. Question Is this intended behavior? Or shouldn't I use phase animator in this way? I could not find any mention of this limitation in the documentation. If it is by design, it might be worth documenting — it is a subtle pitfall that is easy to miss. Thanks in advance for any input!
0
0
89
2d
.contactAccessPicker shows blank sheet on iOS 26.2.1 on device
Calling contactAccessPicker results in a blank sheet and a jetsam error, rather than the expected contact picker, using Apple’s sample code, only on device with iOS 26.2.1. This is happening on a iPhone 17 Pro Max running 26.2.1, and not on a simulator. I’m running Apple's sample project Accessing a person’s contact data using Contacts and ContactsUI Steps: Run the sample app on device running iOS 26.2.1. Use the flow to authorize .limited access with 1 contact: Tap request access, Continue, Select Contacts. Select a contact, Continue, Allow Selected Contact. This all works as expected. Tap the add contact button in the toolbar to add a second contact. Expected: This should show the Contact Access Picker UI. Actual: Sheet is shown with no contents. See screenshot of actual results on iOS device running 26.2.1. Reported as FB21812568 I see a similar (same?) error reported for 26.1. It seems strange that the feature is completely broken for multiple point releases. Is anyone else seeing this or are the two of us running into the same rare edge case? Expected Outcome, seen on simulator running 26.2 Actual outcome, seen on device running 26.2.1
6
2
315
3d
DynamicViewContent and drop validation (macOS)
If I see it correctly, it is currently not possible to validate a drop operation on a DynamicViewContent when using dropDestination? Just a simple example: Let's say I build a folder view on macOS where I can arrange folders freely. In this case I need to use DynamicViewContent.dropDestination to get an insertion index on drop. However, it seems that methods like dropConfiguration do not have any effect. Als dropDestionation(…, isTargeted:) seems not to be available. Here is my sample code: struct FolderRow: View { let folder: Folder var body: some View { DisclosureGroup(isExpanded: .constant(true)) { ForEach(folder.children) { child in FolderRow(folder: child) } .dropDestination(for: Folder.self) { item, idx in print("Dropped at \(idx)") } } label: { Label(folder.name, systemImage: "folder") .draggable(folder) .dropDestination(for: Folder.self) { items, _ in print("Dropped on Item") } } .dropConfiguration { session in DropConfiguration(operation: .move) } } } struct ContentView: View { @State private var folder: Folder = Folder.sampleData @State private var selection: Set<UUID> = [] var body: some View { NavigationSplitView { List(selection: $selection) { FolderRow(folder: folder) } } detail: { EmptyView() } } } The dropConfiguration is applied on the Label (in this case the "Move" cursor is used instead of the "Copy" cursor). Is there any way to do that or is it just an omission in Swift UI?
2
0
176
3d
iOS 26+ UITabBar unselected item colors not updating with UITabBarAppearance
I'm using UITabBarAppearance to customize my TabBar in a SwiftUI app. The customization works perfectly on iOS 18 and earlier, but after updating to iOS 26, the unselected tab items no longer respect my color settings - they just appear black (they are on a white background).Here's my simplified setup: struct ContentView: View { var body: some View { TabView { Text("Home") .tabItem { Image(systemName: "house") Text("Home") } .tag(0) Text("Settings") .tabItem { Image(systemName: "gear") Text("Settings") } .tag(1) } .onAppear { setupTabBarAppearance() } } private func setupTabBarAppearance() { let appearance = UITabBarAppearance() appearance.configureWithOpaqueBackground() let itemAppearance = UITabBarItemAppearance() // These settings work for selected items itemAppearance.selected.iconColor = .systemBlue itemAppearance.selected.titleTextAttributes = [ .font: UIFont.systemFont(ofSize: 10), .foregroundColor: UIColor.systemBlue ] // These settings STOPPED working on iOS 26 for unselected items itemAppearance.normal.iconColor = .gray itemAppearance.normal.titleTextAttributes = [ .font: UIFont.systemFont(ofSize: 10), .foregroundColor: UIColor.gray ] appearance.stackedLayoutAppearance = itemAppearance appearance.inlineLayoutAppearance = itemAppearance appearance.compactInlineLayoutAppearance = itemAppearance UITabBar.appearance().standardAppearance = appearance UITabBar.appearance().scrollEdgeAppearance = appearance } }
1
0
106
4d
ShareLink "Save Image" action dismisses presenting view after saving
When using ShareLink in SwiftUI to share an image, the “Save Image” action dismisses not only the share sheet but also the presenting SwiftUI view. The behavior differs depending on whether the photo library permission alert appears. Observed behavior: The first time the user taps Save Image, the system permission alert appears. After granting permission, the image saves successfully and the share sheet dismisses normally. On subsequent attempts, the image is saved successfully, but both the share sheet and the presenting view are dismissed unexpectedly. Expected behavior: After saving the image, only the share sheet should dismiss. The presenting SwiftUI view should remain visible. Steps to Reproduce Present a SwiftUI view using .sheet. Inside that view, add a ShareLink configured to export a PNG image using Transferable. Tap the ShareLink button. Choose Save Image. Grant permission the first time (if prompted). Repeat the action. Result: On subsequent saves, the share sheet dismisses and the presenting view is dismissed as well. Sample code ` internal import System import UniformTypeIdentifiers import SwiftUI struct RootView: View { @State private var isPresented: Bool = false var body: some View { ZStack { Color.white Button("Show parent view") { isPresented = true } } .sheet(isPresented: $isPresented) { ParentView() } } } struct ParentView: View { @State private var isPresented: Bool = false var body: some View { NavigationStack { ZStack { Color.red.opacity(0.5) } .toolbar { ToolbarItem() { let name = "\(UUID().uuidString)" let image = UIImage(named: "after")! return ShareLink( item: ShareableImage(image: image, fileName: name), preview: SharePreview( name, image: Image(uiImage: image) ) ) { Image(uiImage: UIImage(resource: .Icons.share24)) .resizable() .foregroundStyle(Color.black) .frame(width: 24, height: 24) } } } } } } struct ShareableImage: Transferable { let image: UIImage let fileName: String static var transferRepresentation: some TransferRepresentation { FileRepresentation(exportedContentType: .png) { item in let fileURL = FileManager.default.temporaryDirectory .appendingPathComponent(item.fileName) .appendingPathExtension("png") guard let data = item.image.pngData() else { throw NSError(domain: "ImageEncodingError", code: 0) } try data.write(to: fileURL) return SentTransferredFile(fileURL) } } } `
1
0
54
4d
MultiDatePicker bug in iOS26
Hi! I've encountered strange bug in iOS 26. The MultiDatePicker component exhibits unreliable behavior when attempting to deselect previously chosen dates. Users often need to tap a selected date multiple times (e.g., tap to deselect, tap to re-select, then tap again to deselect) for the UI to correctly register the deselection and update the displayed state. This issue does not occur on iOS 18 or Xcode 26 previews, where MultiDatePicker functions as expected, allowing single-tap deselection. The bug only occurs on physical device or simulator. I can't lie, I have multidatepicker as crucial component in my larger app and can't really find a solution to this. Has anyone encountered this problem before? Here is the code to replicate the issue: import SwiftUI struct ContentView: View {     @ State private var selectedDates: Set = []     var body: some View {         NavigationStack {             Form {                 Section {                     MultiDatePicker("Select Dates", selection: $selectedDates)                 } header: {                     Text("MultiDatePicker Bug Test")                 }                 Section {                     Text("Selected Dates Count: (selectedDates.count)")                     ForEach(Array(selectedDates).sorted(by: {                         Calendar.current.date(from: $0)! < Calendar.current.date(from: $1)!                     }), id: .self) { dateComponent in                         if let date = Calendar.current.date(from: dateComponent) {                             Text(date.formatted(date: .long, time: .omitted))                         }                     }                 } header: {                     Text("Current State of Selected Dates")                 }             }             .navigationTitle("Date Picker Bug")         }     } } #Preview {     ContentView() }
2
1
289
4d
How do you support Preferred Font Size / Dynamic Type on macOS?
On macOS 26, how do you support the Preferred Text Size value as defined in the Accessibility Settings? Historically, "Dynamic Type" has not been available on macOS. However, the user has some control over text size through the Accessibility Settings. On macOS 26, a small subset of applications are honouring changes to that value include Finder, Mail, and sidebars in many applications. Dynamic sizing in table views has been available on macOS for awhile. But Mail.app, in particular, is also adjusting the font sizes used in the message's body pane while the Finder is adjusting font sizes used for Desktop icons. I can't find an NSNotification that is fired when the user adjusts the Accessibility Text Size slider, nor can I find an API to read the current value. NSFont.preferredFont(forTextStyle:options:) looks promising but the fonts returned do not appear to take the user's Accessibility setting into account. (Nor do they update dynamically.) SwiftUI's Text("Apple").font(.body) performs similarly to NSFont in that it does respect the style, but it does not honour dynamic sizing. NSFontDescriptor has a bunch of interesting methods, but none that seem to apply to Accessibility Text Size. Given an AppKit label: let label = NSTextField(labelWithString: "AppKit") label.font = NSFont.preferredFont(forTextStyle: .body) Or a SwiftUI label: Text("SwiftUI").font(.body) How do I make either of them responsive to the user's Text Size setting under Accessibility? Note this is on macOS 26 / Xcode 26. I realize there have been some previous forum posts related to this issue but hoping that things might have improved since then.
2
0
426
5d
TabView with .page style vibrates and reloads content during sheet detent drag
FeedBack Id: FB22031397 (Demo proj Attached to Feedback) Description: When a TabView using .page tabViewStyle is placed inside a sheet configured with multiple presentationDetents, dragging the sheet handle to resize between detents causes the TabView to re-render all its pages on every frame of the drag gesture. This results in visible content vibration, scroll position jumping, and tab content flashing during the drag. The issue is fully reproducible with the attached minimal demo project. Steps to Reproduce: Run the attached TabViewSheetVibrationDemo.swift on any iOS device or simulator Tap "Open Sheet" on the main screen Swipe left to any tab Scroll down inside the tab so content is not at the top Grab the sheet drag indicator at the top and slowly drag upward or downward to resize between medium and large detent Observe the tab content while dragging Expected Results: The TabView page content should remain completely stable during sheet resize. Scroll positions should be preserved and no re-rendering should occur because the underlying data has not changed. The sheet should resize smoothly while tab content stays still. Actual Results: The TabView re-renders all pages on every frame of the drag gesture. This causes: Visible content vibration and jitter while dragging the sheet handle Scroll position jumping back toward the top mid-drag Tab content flashing as pages are recreated The problem is proportional to drag speed — slower drags show a stuttering effect, faster drags cause a full content flash Configuration: All Xcode including beta iOS 26 (also reproduced on iOS 16, iOS 17 and iOS 18) Reproducible on both Simulator and real device Affects iPhone and iPad
1
0
84
1w
Crown Sequencer warning on Scroll
I have a Form (scrollable) that contains 2 inputs as a Picker and a Stepper where frequency is an enum and time an Int. struct ConfigurationView: View { @Bindable var configuration: ConfigurationModel var body: some View { NavigationStack { Form { Picker(.frequency, selection: $configuration.frequency) { /* ... */ } Stepper(value: $configuration.time, in: 1...8) { // Stepper Label } .focusable() Button(.save) { configuration.save() } .buttonStyle(.borderedProminent) .listRowBackground(Color.clear) } .navigationTitle(.configuration) } } } The main issue I'm facing is a delay in the UI (1-3 seconds) while interacting with the Digital Crown over the focused Stepper which prints a Crown Sequencer warning: Crown Sequencer was set up without a view property. This will inevitably lead to incorrect crown indicator states This mainly happens when the Picker, which is showed as a modal or Sheet, changes its value, so the Stepper no longer gets focusable again. Looking into the docs, lectures and WWDC videos I just found that we need to provide a some sort of a focus, that's why the Stepper control has a focusable() modifier. I don't know if there is an overlap between the scroll and the focus event on the control.
1
0
167
1w
ScrollView hicjacking focus in swiftui
Greetings! I'm facing a problem handleling full keyboard access in my app. This is a simpler version of the code: struct PrimerTest: View { @FocusState private var focusedImage: Int? var body: some View { VStack(alignment: .leading, spacing: 20) { Link("Go to google or smth", destination: URL(string: "https://google.com")!) .font(.headline) Text("First text") Text("Second text") HStack { Text("Label") .accessibilityHidden(true) Spacer() Button("Play") { print("Im a button") } } Text("Selecciona un perfil con el teclado (Tab):") .font(.caption) .foregroundColor(.secondary) HStack { ForEach(0..<5, id: \.self) { index in Image(systemName: "person.circle.fill") .resizable() .frame(width: 30, height: 30) .focusable(true) .focused($focusedImage, equals: index) .foregroundStyle(focusedImage == index ? Color.blue : Color.gray) .scaleEffect(focusedImage == index ? 1.2 : 1.0) .animation(.easeInOut, value: focusedImage) .accessibilityHidden(true) } } } .navigationTitle("Title n stuff") .padding() } } And the focus behaves as expected and the important thing, we can access que button on the right side of the screen But as soon as we introduce the scrollview, the right side button is unaccessible, since when we hit tab we go back to the back button in the nav stack header. struct PrimerTest: View { @FocusState private var focusedImage: Int? var body: some View { ScrollView { VStack(alignment: .leading, spacing: 20) { Link("Go to google or smth", destination: URL(string: "https://google.com")!) .font(.headline) Text("First text") Text("Second text") HStack { Text("Label") .accessibilityHidden(true) Spacer() Button("Play") { print("Im a button") } } Text("Selecciona un perfil con el teclado (Tab):") .font(.caption) .foregroundColor(.secondary) HStack { ForEach(0..<5, id: \.self) { index in Image(systemName: "person.circle.fill") .resizable() .frame(width: 30, height: 30) .focusable(true) .focused($focusedImage, equals: index) .foregroundStyle(focusedImage == index ? Color.blue : Color.gray) .scaleEffect(focusedImage == index ? 1.2 : 1.0) .animation(.easeInOut, value: focusedImage) .accessibilityHidden(true) } } } } .navigationTitle("Title n stuff") .padding() } } I've tried all the things I found online and none achieves an acceptable behavoir, I've seen ppl saying this issue has been fixed in ipados with the focusSection modifier, but I have not seen any fix fot this issue in ios.
1
0
720
1w
ShareLink "save Image" action dismiss parent view
ShareLink works fine except for save image action which dismiss the presenting view first time system shows the premission alert so image get saved without any problem but for the next saves image get saved then share sheet dismiss and also presenting view dismiss as well here is a sample code ` internal import System import UniformTypeIdentifiers import SwiftUI struct RootView: View { @State private var isPresented: Bool = false var body: some View { ZStack { Color.white Button("Show parent view") { isPresented = true } } .sheet(isPresented: $isPresented) { ParentView() } } } struct ParentView: View { @State private var isPresented: Bool = false var body: some View { NavigationStack { ZStack { Color.red.opacity(0.5) } .toolbar { ToolbarItem() { let name = "\(UUID().uuidString)" let image = UIImage(named: "after")! return ShareLink( item: ShareableImage(image: image, fileName: name), preview: SharePreview( name, image: Image(uiImage: image) ) ) { Image(uiImage: UIImage(resource: .Icons.share24)) .resizable() .foregroundStyle(Color.black) .frame(width: 24, height: 24) } } } } } } struct ShareableImage: Transferable { let image: UIImage let fileName: String static var transferRepresentation: some TransferRepresentation { FileRepresentation(exportedContentType: .png) { item in let fileURL = FileManager.default.temporaryDirectory .appendingPathComponent(item.fileName) .appendingPathExtension("png") guard let data = item.image.pngData() else { throw NSError(domain: "ImageEncodingError", code: 0) } try data.write(to: fileURL) return SentTransferredFile(fileURL) } } } `
1
0
81
1w
Instruments Crash using swiftui instrument
Instruments is crashing when the swiftui instrument is stopped (the session is finished) and the transfer begins from device to device: Crashed Thread: 11 Dispatch queue: com.apple.swiftuitracingsupport.reading Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4 Terminating Process: exc handler [1633] I've tried removing derived data, reinstalling xcode, updating xcode (I originally thought this might be the issue -- I needed to update to 26.2 from the 26 RC -- the update didn't fix crash or change the crash report), and restarting both devices. I'm running Instruments/Xcode 26.2 on a MacBook Pro 15" (2018) running Mac OS 15.7.2 (24G325) with an iPhone 16 Pro Max running 26.2. Hoping someone else might have seen this or could help me troubleshoot. I find the swiftui instrument be helpful and like to use it :) I can post a complete crash report as well.
5
0
215
1w
Wrong position of searchable component on first render
Hey all, I found a weird behaviour with the searchable component. I created a custom bottom nav bar (because I have custom design in my app) to switch between screens. On one screen I display a List component with the searchable component. Whenever I enter the search screen the first time, the searchable component is displayed at the bottom. This is wrong. It should be displayed at the top under the navigationTitle. When I enter the screen a second time, everything is correct. This behaviour can be reproduced on all iOS 26 versions on the simulator and on a physical device with debug and release build. On iOS 18 everything works fine. Steps to reproduce: Cold start of the app Click on Search TabBarIcon (searchable wrong location) Click on Home TabBarIcon Click on Search TabBarIcon (searchable correct location) Simple code example: import SwiftUI struct ContentView: View { @State var selectedTab: Page = Page.main var body: some View { NavigationStack { ZStack { VStack { switch selectedTab { case .main: MainView() case .search: SearchView() } } VStack { Spacer() VStack(spacing: 0) { HStack(spacing: 0) { TabBarIcon(iconName: "house", selected: selectedTab == .main, displayName: "Home") .onTapGesture { selectedTab = .main } TabBarIcon(iconName: "magnifyingglass", selected: selectedTab == .search, displayName: "Search") .onTapGesture { selectedTab = .search } } .frame(maxWidth: .infinity) .frame(height: 55) .background(Color.gray) } .ignoresSafeArea(.all, edges: .bottom) } } } } } struct TabBarIcon: View { let iconName: String let selected: Bool let displayName: String var body: some View { ZStack { VStack { Image(systemName: iconName) .resizable() .renderingMode(.template) .aspectRatio(contentMode: .fit) .foregroundColor(Color.black) .frame(width: 22, height: 22) Text(displayName) .font(Font.system(size: 10)) } } .frame(maxWidth: .infinity) } } enum Page { case main case search } struct MainView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() .navigationTitle("Home") } } struct SearchView: View { @State private var searchText = "" let items = [ "Apple", "Banana", "Pear", "Strawberry", "Orange", "Peach", "Grape", "Mango" ] var filteredItems: [String] { if searchText.isEmpty { return items } else { return items.filter { $0.localizedCaseInsensitiveContains(searchText) } } } var body: some View { List(filteredItems, id: \.self) { item in Text(item) } .navigationTitle("Fruits") .searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always), prompt: "Search") } }
3
0
211
1w
Two errors in debug: com.apple.modelcatalog.catalog sync and nw_protocol_instance_set_output_handler
We get two error message in Xcode debug. apple.model.catalog we get 1 time at startup, and the nw_protocol_instance_set_output_handler Not calling remove_input_handler on 0x152ac3c00:udp we get on sartup and some time during running of the app. I have tested cutoff repos WS eg. But nothing helpss, thats for the nw_protocol. We have a fondationmodel in a repo but we check if it is available if not we do not touch it. Please help me? nw_protocol_instance_set_output_handler Not calling remove_input_handler on 0x152ac3c00:udp com.apple.modelcatalog.catalog sync: connection error during call: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.modelcatalog.catalog was invalidated: Connection init failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.modelcatalog.catalog was invalidated: Connection init failed at lookup with error 159 - Sandbox restriction.} reached max num connection attempts: 1 The function we have in the repo is this: public actor FoundationRepo: JobDescriptionChecker, SubskillSuggester { private var session: LanguageModelSession? private let isEnabled: Bool private let shouldUseLocalFoundation: Bool private let baseURLString = "https://xx.xx.xxx/xx" private let http: HTTPPac public init(http: HTTPPac, isEnabled: Bool = true) { self.http = http self.isEnabled = isEnabled self.session = nil guard isEnabled else { self.shouldUseLocalFoundation = false return } let model = SystemLanguageModel.default guard model.supportsLocale() else { self.shouldUseLocalFoundation = false return } switch model.availability { case .available: self.shouldUseLocalFoundation = true case .unavailable(.deviceNotEligible), .unavailable(.appleIntelligenceNotEnabled), .unavailable(.modelNotReady): self.shouldUseLocalFoundation = false @unknown default: self.shouldUseLocalFoundation = false } } So here we decide if we are going to use iPhone ML or my backend-remote?
2
0
397
1w
SubscriptionStoreView crashes on macOS Catalyst
I have an iOS and iPadOS app that also runs on macOS Catalyst. The user is able to view their subscription using the SubscriptionStoreView with two SubscriptionOptionGroups. The documentation does not mention these are supported on macOS Catalyst and the app crashes when attempting to show the SubscriptionStoreView on macOS Catalyst. If not supported, how can the user manage their subscription on macOS?
1
0
150
1w
iOS 26: Toolbar button background flashes black during NavigationStack transitions (dark mode)
I’m seeing a visual glitch with toolbar buttons when building with Xcode 26 for iOS 26. During transitions (both pushing in a NavigationStack and presenting a .sheet with its own NavigationStack), the toolbar button briefly flashes the wrong background colour (black in dark mode, white in light mode) before animating to the correct Liquid Glass appearance. This happens even in a minimal example and only seems to affect system toolbar buttons. A custom view with .glassEffect() doesn’t have the issue. I’ve tried: .tint(...), UINavigationBarAppearance/UIToolbarAppearance, and setting backgrounds on hosting/nav/window but none of those made any difference. Here’s a minimal reproducible example: import SwiftUI struct ContentView: View { @State private var showingSheet = false var body: some View { NavigationStack { List { NavigationLink("Push (same stack — morphs)") { DetailView() } Button("Sheet (separate stack — flashes)") { showingSheet = true } } .navigationTitle("Root") .scrollContentBackground(.hidden) .background(.gray) .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Action") {} } } .sheet(isPresented: $showingSheet) { SheetView() } } } } struct DetailView: View { var body: some View { Text("Detail (same stack)") .frame(maxWidth: .infinity, maxHeight: .infinity) .background(.gray) .navigationTitle("Detail") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Action") {} } } } } struct SheetView: View { var body: some View { NavigationStack { Text("Sheet (separate stack)") .frame(maxWidth: .infinity, maxHeight: .infinity) .background(.gray) .navigationTitle("Sheet") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Action") {} } } } } } Has anyone else seen this or found a workaround outside of disabling this background completely with .sharedBackgroundVisibility(.hidden)? I have filed a bug report under FB22141183
Replies
0
Boosts
0
Views
38
Activity
6h
Now Available: Wishlist Sample Code for SwiftUI
We’ve just added a new sample code project to the SwiftUI Essentials documentation! If you attended the recent SwiftUI foundations: Build great apps with SwiftUI activity, you might recognize Wishlist, our travel-planning sample app. You can now explore and download the complete project here
Replies
0
Boosts
1
Views
37
Activity
1d
Glass Effect Label Shadow Clipping During Morph Animation
Hi all, I’m experiencing a visual bug when applying the glass effect to a Label in Liquid Glass (current version 26.2 on simulator; also reproducible in 26.3.1 on device). Issue: On a label with .glassEffect(.regular), when collapsing via morph animation, the shadow is clipped during the animation, and then suddenly "pops" back to its un-clipped state, resulting in a jarring visual effect. Minimal Example: import SwiftUI struct ContentView: View { var body: some View { Menu { Button("Duplicate", action: {}) Button("Rename", action: {}) Button("Delete…", action: {}) } label: { Label("PDF", systemImage: "doc.fill") .padding() .glassEffect(.regular) } } } #Preview { ContentView() } I am not sure if I am misusing the .glassEffect() on the label and maybe there is another more native way of achieving this look? Any advice or workaround suggestions would be greatly appreciated!
Replies
2
Boosts
0
Views
56
Activity
1d
Back gesture not disabled with navigationBarBackButtonHidden(true) when using .zoom transition
[Submitted as FB22226720] For a NavigationStack destination, applying .navigationBarBackButtonHidden(true) hides the back button and also disables the interactive left-edge back gesture when using the standard push navigation transition. However, when the destination uses .navigationTransition(.zoom), the back button is hidden but the left-edge back gesture is still available—it can still be dismissed even though back is intentionally suppressed. This creates inconsistent behavior between navigation transition styles. navigationBarBackButtonHidden(_:) works with a standard push transition, but not with .navigationTransition(.zoom). In the code below, .interactiveDismissDisabled(true) is also applied as another attempt to suppress the back-swipe gesture, but it has no effect. As a result, there’s currently no clean way to prevent back navigation when using the zoom transition. REPRO STEPS Create an iOS project then replace ContentView with code below, build and run. Leave nav type set to List Push. Open an item. Verify there is no back button, then try the left-edge back gesture. Return to the root view. Change nav type to Grid Zoom. Open an item. Verify there is no back button, then try the left-edge back gesture. ACTUAL In List Push mode, the left-edge back gesture is prevented. In Grid Zoom mode, the back button is hidden, but the left-edge back gesture still works and returns to the previous view. EXPECTED Behavior should be consistent across navigation transition styles. If this configuration is meant to suppress interactive backward navigation for a destination, it should also suppress the left-edge back gesture when using .navigationTransition(.zoom). SCREEN RECORDING SAMPLE CODE struct ContentView: View { private enum NavigationMode: String, CaseIterable { case listPush = "List Push" case gridZoom = "Grid Zoom" } @Namespace private var namespace @State private var navigationMode: NavigationMode = .listPush private let colors: [Color] = [.red, .blue] var body: some View { NavigationStack { VStack(spacing: 16) { Picker("Navigation Type", selection: $navigationMode) { ForEach(NavigationMode.allCases, id: \.self) { mode in Text(mode.rawValue).tag(mode) } } .pickerStyle(.segmented) if navigationMode == .gridZoom { HStack { ForEach(colors.indices, id: \.self) { index in NavigationLink(value: index) { VStack { RoundedRectangle(cornerRadius: 14) .fill(colors[index]) .frame(height: 120) Text("Grid Item \(index + 1)") .font(.subheadline.weight(.medium)) } .padding(12) .frame(maxWidth: .infinity) .background(.quaternary.opacity(0.25), in: RoundedRectangle(cornerRadius: 16)) .matchedTransitionSource(id: index, in: namespace) } .buttonStyle(.plain) } } } else { ForEach(colors.indices, id: \.self) { index in NavigationLink(value: index) { HStack { Circle() .fill(colors[index]) .frame(width: 24, height: 24) Text("List Item \(index + 1)") Spacer() Image(systemName: "chevron.right") .foregroundStyle(.secondary) } .padding() .background(.quaternary.opacity(0.25), in: RoundedRectangle(cornerRadius: 12)) } .buttonStyle(.plain) } } Spacer() } .padding(20) .navigationTitle("Prevent Back Swipe") .navigationSubtitle("Compare Grid Zoom vs List Push") .navigationDestination(for: Int.self) { index in if navigationMode == .gridZoom { DetailView(color: colors[index]) .navigationTransition(.zoom(sourceID: index, in: namespace)) } else { DetailView(color: colors[index]) } } } } } private struct DetailView: View { @Environment(\.dismiss) private var dismiss let color: Color var body: some View { ZStack { color.ignoresSafeArea() Text("Try left-edge swipe back") .font(.title.bold()) .multilineTextAlignment(.center) .padding(.horizontal, 24) } .navigationBarBackButtonHidden(true) .interactiveDismissDisabled(true) .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Close", action: dismiss.callAsFunction) } } } }
Replies
2
Boosts
0
Views
556
Activity
1d
hapticpatternlibrary.plist error with Text entry fields in Simulator only
When I have a TextField or TextEditor, tapping into it produces these two console entries about 18 times each: CHHapticPattern.mm:487 +[CHHapticPattern patternForKey:error:]: Failed to read pattern library data: Error Domain=NSCocoaErrorDomain Code=260 "The file “hapticpatternlibrary.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, NSURL=file:///Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, NSUnderlyingError=0x600000ca1b30 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} <_UIKBFeedbackGenerator: 0x600003505290>: Error creating CHHapticPattern: Error Domain=NSCocoaErrorDomain Code=260 "The file “hapticpatternlibrary.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, NSURL=file:///Library/Audio/Tunings/Generic/Haptics/Library/hapticpatternlibrary.plist, NSUnderlyingError=0x600000ca1b30 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} My app does not use haptics. This doesn't appear to cause any issues, although entering text can feel a bit sluggish (even on device), but I am unable to determine relatedness. None-the-less, it definitely is a lot of log noise. Code to reproduce in simulator (xcode 26.2; ios 26 or 18, with iPhone 16 Pro or iPhone 17 Pro): import SwiftUI struct ContentView: View { @State private var textEntered: String = "" @State private var textEntered2: String = "" @State private var textEntered3: String = "" var body: some View { VStack { Spacer() TextField("Tap Here", text: $textEntered) TextField("Tap Here Too", text: $textEntered2) TextEditor(text: $textEntered3) .overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(.primary, lineWidth: 1)) .frame(height: 100) Spacer() } } } #Preview { ContentView() } Tapping back and forth in these fields generates the errors each time. Thanks, Steve
Replies
4
Boosts
0
Views
647
Activity
1d
PhaseAnimator doesn't reflect @Observable state changes after animation settles
I ran into a behavior with PhaseAnimator that I'm not sure is a bug or by design. I'd appreciate any insight. The Problem When an @Observable property is read only inside a PhaseAnimator content closure, changes to that property are ignored after the animation cycle completes and reaches its resting state. The UI gets stuck showing stale data. Minimal Reproduction I've put together a simple demo with two views side by side, both driven by the same ViewModel and toggled by the same button: BrokenView — receives an @Observable object and reads its property inside PhaseAnimator. After the animation completes, toggling the property has no visible effect. FixedView — receives the same value as a Bool parameter. Updates correctly every time because view's parameter has changed. import SwiftUI @Observable class ViewModel { var isError = false } struct BrokenView: View { let viewModel: ViewModel @State private var trigger = false var body: some View { VStack(spacing: 20) { Text("Broken (@Observable)").font(.headline) PhaseAnimator([false, true], trigger: trigger) { _ in if viewModel.isError { Text("Error!").foregroundStyle(.red).font(.largeTitle) } else { Text("OK").foregroundStyle(.green).font(.largeTitle) } } } .padding() .onAppear { trigger = true } } } struct FixedView: View { let isError: Bool @State private var trigger = false var body: some View { VStack(spacing: 20) { Text("Fixed (Value Type)").font(.headline) PhaseAnimator([false, true], trigger: trigger) { _ in if isError { Text("Error!").foregroundStyle(.red).font(.largeTitle) } else { Text("OK").foregroundStyle(.green).font(.largeTitle) } } } .padding() .onAppear { trigger = true } } } struct DemoView: View { @State private var viewModel = ViewModel() var body: some View { VStack(spacing: 40) { BrokenView(viewModel: viewModel) Divider() FixedView(isError: viewModel.isError) Divider() Button("Toggle isError: \(viewModel.isError)") { viewModel.isError.toggle() } .buttonStyle(.borderedProminent) } .padding() } } Run the preview, then tap the toggle button. FixedView updates instantly; BrokenView stays stuck. My Understanding It seems like PhaseAnimator only tracks @Observable access during active animation phases. Once it settles at rest, the content closure is not re-evaluated, so observation tracking is effectively lost. Passing a value type works because SwiftUI view diffing detects the input change and triggers a body re-evaluation, which in turn re-evaluates the PhaseAnimator content. Question Is this intended behavior? Or shouldn't I use phase animator in this way? I could not find any mention of this limitation in the documentation. If it is by design, it might be worth documenting — it is a subtle pitfall that is easy to miss. Thanks in advance for any input!
Replies
0
Boosts
0
Views
89
Activity
2d
.contactAccessPicker shows blank sheet on iOS 26.2.1 on device
Calling contactAccessPicker results in a blank sheet and a jetsam error, rather than the expected contact picker, using Apple’s sample code, only on device with iOS 26.2.1. This is happening on a iPhone 17 Pro Max running 26.2.1, and not on a simulator. I’m running Apple's sample project Accessing a person’s contact data using Contacts and ContactsUI Steps: Run the sample app on device running iOS 26.2.1. Use the flow to authorize .limited access with 1 contact: Tap request access, Continue, Select Contacts. Select a contact, Continue, Allow Selected Contact. This all works as expected. Tap the add contact button in the toolbar to add a second contact. Expected: This should show the Contact Access Picker UI. Actual: Sheet is shown with no contents. See screenshot of actual results on iOS device running 26.2.1. Reported as FB21812568 I see a similar (same?) error reported for 26.1. It seems strange that the feature is completely broken for multiple point releases. Is anyone else seeing this or are the two of us running into the same rare edge case? Expected Outcome, seen on simulator running 26.2 Actual outcome, seen on device running 26.2.1
Replies
6
Boosts
2
Views
315
Activity
3d
DynamicViewContent and drop validation (macOS)
If I see it correctly, it is currently not possible to validate a drop operation on a DynamicViewContent when using dropDestination? Just a simple example: Let's say I build a folder view on macOS where I can arrange folders freely. In this case I need to use DynamicViewContent.dropDestination to get an insertion index on drop. However, it seems that methods like dropConfiguration do not have any effect. Als dropDestionation(…, isTargeted:) seems not to be available. Here is my sample code: struct FolderRow: View { let folder: Folder var body: some View { DisclosureGroup(isExpanded: .constant(true)) { ForEach(folder.children) { child in FolderRow(folder: child) } .dropDestination(for: Folder.self) { item, idx in print("Dropped at \(idx)") } } label: { Label(folder.name, systemImage: "folder") .draggable(folder) .dropDestination(for: Folder.self) { items, _ in print("Dropped on Item") } } .dropConfiguration { session in DropConfiguration(operation: .move) } } } struct ContentView: View { @State private var folder: Folder = Folder.sampleData @State private var selection: Set<UUID> = [] var body: some View { NavigationSplitView { List(selection: $selection) { FolderRow(folder: folder) } } detail: { EmptyView() } } } The dropConfiguration is applied on the Label (in this case the "Move" cursor is used instead of the "Copy" cursor). Is there any way to do that or is it just an omission in Swift UI?
Replies
2
Boosts
0
Views
176
Activity
3d
iOS 26+ UITabBar unselected item colors not updating with UITabBarAppearance
I'm using UITabBarAppearance to customize my TabBar in a SwiftUI app. The customization works perfectly on iOS 18 and earlier, but after updating to iOS 26, the unselected tab items no longer respect my color settings - they just appear black (they are on a white background).Here's my simplified setup: struct ContentView: View { var body: some View { TabView { Text("Home") .tabItem { Image(systemName: "house") Text("Home") } .tag(0) Text("Settings") .tabItem { Image(systemName: "gear") Text("Settings") } .tag(1) } .onAppear { setupTabBarAppearance() } } private func setupTabBarAppearance() { let appearance = UITabBarAppearance() appearance.configureWithOpaqueBackground() let itemAppearance = UITabBarItemAppearance() // These settings work for selected items itemAppearance.selected.iconColor = .systemBlue itemAppearance.selected.titleTextAttributes = [ .font: UIFont.systemFont(ofSize: 10), .foregroundColor: UIColor.systemBlue ] // These settings STOPPED working on iOS 26 for unselected items itemAppearance.normal.iconColor = .gray itemAppearance.normal.titleTextAttributes = [ .font: UIFont.systemFont(ofSize: 10), .foregroundColor: UIColor.gray ] appearance.stackedLayoutAppearance = itemAppearance appearance.inlineLayoutAppearance = itemAppearance appearance.compactInlineLayoutAppearance = itemAppearance UITabBar.appearance().standardAppearance = appearance UITabBar.appearance().scrollEdgeAppearance = appearance } }
Replies
1
Boosts
0
Views
106
Activity
4d
ShareLink "Save Image" action dismisses presenting view after saving
When using ShareLink in SwiftUI to share an image, the “Save Image” action dismisses not only the share sheet but also the presenting SwiftUI view. The behavior differs depending on whether the photo library permission alert appears. Observed behavior: The first time the user taps Save Image, the system permission alert appears. After granting permission, the image saves successfully and the share sheet dismisses normally. On subsequent attempts, the image is saved successfully, but both the share sheet and the presenting view are dismissed unexpectedly. Expected behavior: After saving the image, only the share sheet should dismiss. The presenting SwiftUI view should remain visible. Steps to Reproduce Present a SwiftUI view using .sheet. Inside that view, add a ShareLink configured to export a PNG image using Transferable. Tap the ShareLink button. Choose Save Image. Grant permission the first time (if prompted). Repeat the action. Result: On subsequent saves, the share sheet dismisses and the presenting view is dismissed as well. Sample code ` internal import System import UniformTypeIdentifiers import SwiftUI struct RootView: View { @State private var isPresented: Bool = false var body: some View { ZStack { Color.white Button("Show parent view") { isPresented = true } } .sheet(isPresented: $isPresented) { ParentView() } } } struct ParentView: View { @State private var isPresented: Bool = false var body: some View { NavigationStack { ZStack { Color.red.opacity(0.5) } .toolbar { ToolbarItem() { let name = "\(UUID().uuidString)" let image = UIImage(named: "after")! return ShareLink( item: ShareableImage(image: image, fileName: name), preview: SharePreview( name, image: Image(uiImage: image) ) ) { Image(uiImage: UIImage(resource: .Icons.share24)) .resizable() .foregroundStyle(Color.black) .frame(width: 24, height: 24) } } } } } } struct ShareableImage: Transferable { let image: UIImage let fileName: String static var transferRepresentation: some TransferRepresentation { FileRepresentation(exportedContentType: .png) { item in let fileURL = FileManager.default.temporaryDirectory .appendingPathComponent(item.fileName) .appendingPathExtension("png") guard let data = item.image.pngData() else { throw NSError(domain: "ImageEncodingError", code: 0) } try data.write(to: fileURL) return SentTransferredFile(fileURL) } } } `
Replies
1
Boosts
0
Views
54
Activity
4d
MultiDatePicker bug in iOS26
Hi! I've encountered strange bug in iOS 26. The MultiDatePicker component exhibits unreliable behavior when attempting to deselect previously chosen dates. Users often need to tap a selected date multiple times (e.g., tap to deselect, tap to re-select, then tap again to deselect) for the UI to correctly register the deselection and update the displayed state. This issue does not occur on iOS 18 or Xcode 26 previews, where MultiDatePicker functions as expected, allowing single-tap deselection. The bug only occurs on physical device or simulator. I can't lie, I have multidatepicker as crucial component in my larger app and can't really find a solution to this. Has anyone encountered this problem before? Here is the code to replicate the issue: import SwiftUI struct ContentView: View {     @ State private var selectedDates: Set = []     var body: some View {         NavigationStack {             Form {                 Section {                     MultiDatePicker("Select Dates", selection: $selectedDates)                 } header: {                     Text("MultiDatePicker Bug Test")                 }                 Section {                     Text("Selected Dates Count: (selectedDates.count)")                     ForEach(Array(selectedDates).sorted(by: {                         Calendar.current.date(from: $0)! < Calendar.current.date(from: $1)!                     }), id: .self) { dateComponent in                         if let date = Calendar.current.date(from: dateComponent) {                             Text(date.formatted(date: .long, time: .omitted))                         }                     }                 } header: {                     Text("Current State of Selected Dates")                 }             }             .navigationTitle("Date Picker Bug")         }     } } #Preview {     ContentView() }
Replies
2
Boosts
1
Views
289
Activity
4d
How do you support Preferred Font Size / Dynamic Type on macOS?
On macOS 26, how do you support the Preferred Text Size value as defined in the Accessibility Settings? Historically, "Dynamic Type" has not been available on macOS. However, the user has some control over text size through the Accessibility Settings. On macOS 26, a small subset of applications are honouring changes to that value include Finder, Mail, and sidebars in many applications. Dynamic sizing in table views has been available on macOS for awhile. But Mail.app, in particular, is also adjusting the font sizes used in the message's body pane while the Finder is adjusting font sizes used for Desktop icons. I can't find an NSNotification that is fired when the user adjusts the Accessibility Text Size slider, nor can I find an API to read the current value. NSFont.preferredFont(forTextStyle:options:) looks promising but the fonts returned do not appear to take the user's Accessibility setting into account. (Nor do they update dynamically.) SwiftUI's Text("Apple").font(.body) performs similarly to NSFont in that it does respect the style, but it does not honour dynamic sizing. NSFontDescriptor has a bunch of interesting methods, but none that seem to apply to Accessibility Text Size. Given an AppKit label: let label = NSTextField(labelWithString: "AppKit") label.font = NSFont.preferredFont(forTextStyle: .body) Or a SwiftUI label: Text("SwiftUI").font(.body) How do I make either of them responsive to the user's Text Size setting under Accessibility? Note this is on macOS 26 / Xcode 26. I realize there have been some previous forum posts related to this issue but hoping that things might have improved since then.
Replies
2
Boosts
0
Views
426
Activity
5d
TabView with .page style vibrates and reloads content during sheet detent drag
FeedBack Id: FB22031397 (Demo proj Attached to Feedback) Description: When a TabView using .page tabViewStyle is placed inside a sheet configured with multiple presentationDetents, dragging the sheet handle to resize between detents causes the TabView to re-render all its pages on every frame of the drag gesture. This results in visible content vibration, scroll position jumping, and tab content flashing during the drag. The issue is fully reproducible with the attached minimal demo project. Steps to Reproduce: Run the attached TabViewSheetVibrationDemo.swift on any iOS device or simulator Tap "Open Sheet" on the main screen Swipe left to any tab Scroll down inside the tab so content is not at the top Grab the sheet drag indicator at the top and slowly drag upward or downward to resize between medium and large detent Observe the tab content while dragging Expected Results: The TabView page content should remain completely stable during sheet resize. Scroll positions should be preserved and no re-rendering should occur because the underlying data has not changed. The sheet should resize smoothly while tab content stays still. Actual Results: The TabView re-renders all pages on every frame of the drag gesture. This causes: Visible content vibration and jitter while dragging the sheet handle Scroll position jumping back toward the top mid-drag Tab content flashing as pages are recreated The problem is proportional to drag speed — slower drags show a stuttering effect, faster drags cause a full content flash Configuration: All Xcode including beta iOS 26 (also reproduced on iOS 16, iOS 17 and iOS 18) Reproducible on both Simulator and real device Affects iPhone and iPad
Replies
1
Boosts
0
Views
84
Activity
1w
Crown Sequencer warning on Scroll
I have a Form (scrollable) that contains 2 inputs as a Picker and a Stepper where frequency is an enum and time an Int. struct ConfigurationView: View { @Bindable var configuration: ConfigurationModel var body: some View { NavigationStack { Form { Picker(.frequency, selection: $configuration.frequency) { /* ... */ } Stepper(value: $configuration.time, in: 1...8) { // Stepper Label } .focusable() Button(.save) { configuration.save() } .buttonStyle(.borderedProminent) .listRowBackground(Color.clear) } .navigationTitle(.configuration) } } } The main issue I'm facing is a delay in the UI (1-3 seconds) while interacting with the Digital Crown over the focused Stepper which prints a Crown Sequencer warning: Crown Sequencer was set up without a view property. This will inevitably lead to incorrect crown indicator states This mainly happens when the Picker, which is showed as a modal or Sheet, changes its value, so the Stepper no longer gets focusable again. Looking into the docs, lectures and WWDC videos I just found that we need to provide a some sort of a focus, that's why the Stepper control has a focusable() modifier. I don't know if there is an overlap between the scroll and the focus event on the control.
Replies
1
Boosts
0
Views
167
Activity
1w
ScrollView hicjacking focus in swiftui
Greetings! I'm facing a problem handleling full keyboard access in my app. This is a simpler version of the code: struct PrimerTest: View { @FocusState private var focusedImage: Int? var body: some View { VStack(alignment: .leading, spacing: 20) { Link("Go to google or smth", destination: URL(string: "https://google.com")!) .font(.headline) Text("First text") Text("Second text") HStack { Text("Label") .accessibilityHidden(true) Spacer() Button("Play") { print("Im a button") } } Text("Selecciona un perfil con el teclado (Tab):") .font(.caption) .foregroundColor(.secondary) HStack { ForEach(0..<5, id: \.self) { index in Image(systemName: "person.circle.fill") .resizable() .frame(width: 30, height: 30) .focusable(true) .focused($focusedImage, equals: index) .foregroundStyle(focusedImage == index ? Color.blue : Color.gray) .scaleEffect(focusedImage == index ? 1.2 : 1.0) .animation(.easeInOut, value: focusedImage) .accessibilityHidden(true) } } } .navigationTitle("Title n stuff") .padding() } } And the focus behaves as expected and the important thing, we can access que button on the right side of the screen But as soon as we introduce the scrollview, the right side button is unaccessible, since when we hit tab we go back to the back button in the nav stack header. struct PrimerTest: View { @FocusState private var focusedImage: Int? var body: some View { ScrollView { VStack(alignment: .leading, spacing: 20) { Link("Go to google or smth", destination: URL(string: "https://google.com")!) .font(.headline) Text("First text") Text("Second text") HStack { Text("Label") .accessibilityHidden(true) Spacer() Button("Play") { print("Im a button") } } Text("Selecciona un perfil con el teclado (Tab):") .font(.caption) .foregroundColor(.secondary) HStack { ForEach(0..<5, id: \.self) { index in Image(systemName: "person.circle.fill") .resizable() .frame(width: 30, height: 30) .focusable(true) .focused($focusedImage, equals: index) .foregroundStyle(focusedImage == index ? Color.blue : Color.gray) .scaleEffect(focusedImage == index ? 1.2 : 1.0) .animation(.easeInOut, value: focusedImage) .accessibilityHidden(true) } } } } .navigationTitle("Title n stuff") .padding() } } I've tried all the things I found online and none achieves an acceptable behavoir, I've seen ppl saying this issue has been fixed in ipados with the focusSection modifier, but I have not seen any fix fot this issue in ios.
Replies
1
Boosts
0
Views
720
Activity
1w
ShareLink "save Image" action dismiss parent view
ShareLink works fine except for save image action which dismiss the presenting view first time system shows the premission alert so image get saved without any problem but for the next saves image get saved then share sheet dismiss and also presenting view dismiss as well here is a sample code ` internal import System import UniformTypeIdentifiers import SwiftUI struct RootView: View { @State private var isPresented: Bool = false var body: some View { ZStack { Color.white Button("Show parent view") { isPresented = true } } .sheet(isPresented: $isPresented) { ParentView() } } } struct ParentView: View { @State private var isPresented: Bool = false var body: some View { NavigationStack { ZStack { Color.red.opacity(0.5) } .toolbar { ToolbarItem() { let name = "\(UUID().uuidString)" let image = UIImage(named: "after")! return ShareLink( item: ShareableImage(image: image, fileName: name), preview: SharePreview( name, image: Image(uiImage: image) ) ) { Image(uiImage: UIImage(resource: .Icons.share24)) .resizable() .foregroundStyle(Color.black) .frame(width: 24, height: 24) } } } } } } struct ShareableImage: Transferable { let image: UIImage let fileName: String static var transferRepresentation: some TransferRepresentation { FileRepresentation(exportedContentType: .png) { item in let fileURL = FileManager.default.temporaryDirectory .appendingPathComponent(item.fileName) .appendingPathExtension("png") guard let data = item.image.pngData() else { throw NSError(domain: "ImageEncodingError", code: 0) } try data.write(to: fileURL) return SentTransferredFile(fileURL) } } } `
Replies
1
Boosts
0
Views
81
Activity
1w
Instruments Crash using swiftui instrument
Instruments is crashing when the swiftui instrument is stopped (the session is finished) and the transfer begins from device to device: Crashed Thread: 11 Dispatch queue: com.apple.swiftuitracingsupport.reading Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4 Terminating Process: exc handler [1633] I've tried removing derived data, reinstalling xcode, updating xcode (I originally thought this might be the issue -- I needed to update to 26.2 from the 26 RC -- the update didn't fix crash or change the crash report), and restarting both devices. I'm running Instruments/Xcode 26.2 on a MacBook Pro 15" (2018) running Mac OS 15.7.2 (24G325) with an iPhone 16 Pro Max running 26.2. Hoping someone else might have seen this or could help me troubleshoot. I find the swiftui instrument be helpful and like to use it :) I can post a complete crash report as well.
Replies
5
Boosts
0
Views
215
Activity
1w
Wrong position of searchable component on first render
Hey all, I found a weird behaviour with the searchable component. I created a custom bottom nav bar (because I have custom design in my app) to switch between screens. On one screen I display a List component with the searchable component. Whenever I enter the search screen the first time, the searchable component is displayed at the bottom. This is wrong. It should be displayed at the top under the navigationTitle. When I enter the screen a second time, everything is correct. This behaviour can be reproduced on all iOS 26 versions on the simulator and on a physical device with debug and release build. On iOS 18 everything works fine. Steps to reproduce: Cold start of the app Click on Search TabBarIcon (searchable wrong location) Click on Home TabBarIcon Click on Search TabBarIcon (searchable correct location) Simple code example: import SwiftUI struct ContentView: View { @State var selectedTab: Page = Page.main var body: some View { NavigationStack { ZStack { VStack { switch selectedTab { case .main: MainView() case .search: SearchView() } } VStack { Spacer() VStack(spacing: 0) { HStack(spacing: 0) { TabBarIcon(iconName: "house", selected: selectedTab == .main, displayName: "Home") .onTapGesture { selectedTab = .main } TabBarIcon(iconName: "magnifyingglass", selected: selectedTab == .search, displayName: "Search") .onTapGesture { selectedTab = .search } } .frame(maxWidth: .infinity) .frame(height: 55) .background(Color.gray) } .ignoresSafeArea(.all, edges: .bottom) } } } } } struct TabBarIcon: View { let iconName: String let selected: Bool let displayName: String var body: some View { ZStack { VStack { Image(systemName: iconName) .resizable() .renderingMode(.template) .aspectRatio(contentMode: .fit) .foregroundColor(Color.black) .frame(width: 22, height: 22) Text(displayName) .font(Font.system(size: 10)) } } .frame(maxWidth: .infinity) } } enum Page { case main case search } struct MainView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() .navigationTitle("Home") } } struct SearchView: View { @State private var searchText = "" let items = [ "Apple", "Banana", "Pear", "Strawberry", "Orange", "Peach", "Grape", "Mango" ] var filteredItems: [String] { if searchText.isEmpty { return items } else { return items.filter { $0.localizedCaseInsensitiveContains(searchText) } } } var body: some View { List(filteredItems, id: \.self) { item in Text(item) } .navigationTitle("Fruits") .searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always), prompt: "Search") } }
Replies
3
Boosts
0
Views
211
Activity
1w
Two errors in debug: com.apple.modelcatalog.catalog sync and nw_protocol_instance_set_output_handler
We get two error message in Xcode debug. apple.model.catalog we get 1 time at startup, and the nw_protocol_instance_set_output_handler Not calling remove_input_handler on 0x152ac3c00:udp we get on sartup and some time during running of the app. I have tested cutoff repos WS eg. But nothing helpss, thats for the nw_protocol. We have a fondationmodel in a repo but we check if it is available if not we do not touch it. Please help me? nw_protocol_instance_set_output_handler Not calling remove_input_handler on 0x152ac3c00:udp com.apple.modelcatalog.catalog sync: connection error during call: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.modelcatalog.catalog was invalidated: Connection init failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.modelcatalog.catalog was invalidated: Connection init failed at lookup with error 159 - Sandbox restriction.} reached max num connection attempts: 1 The function we have in the repo is this: public actor FoundationRepo: JobDescriptionChecker, SubskillSuggester { private var session: LanguageModelSession? private let isEnabled: Bool private let shouldUseLocalFoundation: Bool private let baseURLString = "https://xx.xx.xxx/xx" private let http: HTTPPac public init(http: HTTPPac, isEnabled: Bool = true) { self.http = http self.isEnabled = isEnabled self.session = nil guard isEnabled else { self.shouldUseLocalFoundation = false return } let model = SystemLanguageModel.default guard model.supportsLocale() else { self.shouldUseLocalFoundation = false return } switch model.availability { case .available: self.shouldUseLocalFoundation = true case .unavailable(.deviceNotEligible), .unavailable(.appleIntelligenceNotEnabled), .unavailable(.modelNotReady): self.shouldUseLocalFoundation = false @unknown default: self.shouldUseLocalFoundation = false } } So here we decide if we are going to use iPhone ML or my backend-remote?
Replies
2
Boosts
0
Views
397
Activity
1w
SubscriptionStoreView crashes on macOS Catalyst
I have an iOS and iPadOS app that also runs on macOS Catalyst. The user is able to view their subscription using the SubscriptionStoreView with two SubscriptionOptionGroups. The documentation does not mention these are supported on macOS Catalyst and the app crashes when attempting to show the SubscriptionStoreView on macOS Catalyst. If not supported, how can the user manage their subscription on macOS?
Replies
1
Boosts
0
Views
150
Activity
1w