When navigated to another view with a NavigationStack or NavigationView, the .navigationTitle modifying a List or Form containing a Map() gets quirky when trying to show the title. The back button is displayed correctly, but the title does not follow the same color scheme as the List of Form, rather it is white with a divider underneath it. It's like it is confusing the .inline with the .large navigation display modes. This doesn't just show up in the simulator, but on actual devices too.
This is a test main view...
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
NavigationLink(destination: MapErrorView()) {
Text("Map View")
}
}
}
}
This is a test navigated view...
import SwiftUI
import MapKit
struct MapErrorView: View {
var body: some View {
NavigationStack {
Form {
Section(header: Text("Map of the US States")) {
Text("Map Error")
Map()
.frame(height: 220)
}
}
.navigationTitle("Map Error")
.navigationBarTitleDisplayMode(.large)
}
}
}
Attached is an image showing this error occurring. Does anyone know how I can get around this without using Text() to mock it? That might be the only way to get around this error.
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Posts under SwiftUI tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm trying to have a RoundedRectangle with a slightly different color border (stroke in this case) with a shadow behind it. The issue I'm having is that the shadow itself is being drawn overtop the stroke. I've tried using a ZStack with another RoundedRectangle in the background with a shadow, but I kept running into the same issue.
Anyone have any better ideas?
Section {
VStack {
RoundedRectangle(cornerRadius: 11)
.fill(color.shadow(.drop(color: .gray, radius: 2, x: 2, y: 2)))
.stroke(color.opacity(0.5), lineWidth: 5)
}
.frame(height: 200)
.padding()
}
.listRowInsets(EdgeInsets()) // Remove padding inside section, but causes clipping on the RoundedRectangle stroke
.listRowBackground(Color.clear) // Remove background color
how to get a clear background with navigationstack in visionOS app?
This app will not crash when switching between these two tabs with TabView init(content:)
import SwiftUI
import SwiftData
struct ContentView: View {
@StateObject private var highlightManager = HighlightManager.shared
@State private var selectedTab: Int = 0
var body: some View {
TabView(selection: $selectedTab) {
MapView()
.tabItem {
Label("Map", systemImage: "map")
}
.tag(0)
// Annotation Tab
AnnotationList()
.tabItem {
Label("Annotation", systemImage: "mappin.and.ellipse")
}
.tag(1)
// Group Tab
PeopleList()
.tabItem {
Label("Group", systemImage: "person.and.person")
}
.tag(2)
}
.tutorialOverlay() // Apply the overlay to the root view
.environmentObject(highlightManager)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
NavigationLink("Help") {
NavigationStack {
HelpView(selectedTab: selectedTab)
}
}
}
}
}
}
For a large / older iOS app project, we have noticed the the view hierarchy debugger works fine for our UIKit screens, but runs into the following crasher whenever we try to launch the view hierarchy debugger on a UIHostingVC screen with SwiftUI content:
Unable to capture the view hierarchy "AppName" encountered an unexpected error when processing the request for a view hierarchy snapshot.
--
The operation couldn’t be completed. Log Title: Data source expression execution failure.
Log Details: error evaluating expression “(BOOL)[[(Class)objc_getClass("DebugHierarchyTargetHub") sharedHub] performRequestInPlaceWithRequestInBase64:@"..."]”: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=2, address=0x16b23bff8).
Has anyone successfully resolved the underlying issue in this crasher? Tried all the typical recommendations for a clean build, clear derived data, use the "Debug -> View Debugging" menu - all with no resolution.
Reported using Feedback Assistant: FB18514200
Thanks
Take a look at following sample code.
verify the shapes of two toolbar buttons.
remove .matchedTransitionSource(id: 1, in: navigationNamespace) for one button.
verify the toolbar button shape is changed to normal circle shape
The combination usage of matchedTransitionSource and sharedBackgroundVisibility leads to unexpected display result.
Removing any of these two view modifier restores the correct display.
None of the view modifiers indicates it will crop the button shape.
struct ContentView: View {
@Namespace var navigationNamespace
var body: some View {
NavigationStack {
ZStack {
Color.gray
}
.ignoresSafeArea()
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
} label: {
Image(systemName: "person")
.font(.title3)
.foregroundStyle(Color.accentColor)
.frame(width: 50, height: 50)
.glassEffect(
.regular.interactive(),
in: .circle
)
}
.matchedTransitionSource(id: 1, in: navigationNamespace)
}
.sharedBackgroundVisibility(.hidden)
ToolbarItem(placement: .topBarTrailing) {
Button {
} label: {
Image(systemName: "square.and.pencil")
.font(.title3)
.foregroundStyle(Color.accentColor)
.frame(width: 50, height: 50)
.glassEffect(
.regular.interactive(),
in: .circle
)
}
.matchedTransitionSource(id: 1, in: navigationNamespace)
}
.sharedBackgroundVisibility(.hidden)
}
}
}
}
#Preview {
ContentView()
}
On iPadOS 26, dragging my draggable() View near the edge of the screen is causing a new window to open.
This doesn't happen with .onDrag on iPadOS 26, or with either .draggable() or .onDrag on iPadOS 18.5.
This is not something I'm intending to offer in my app, and doesn't really make sense. Is there any way to prevent this from happening? Is this a bug? I couldn't find any new documentation.
The thing being dragged: the "Font" rectangle on the right side of the screen, which represents an item in my app that is reorder-able when multiple are present.
I'm building an iPad app targeting iPadOS 26 using SwiftUI. Previously, I added a custom button by overlaying it in the top-left corner:
content
.overlay(alignment: .topLeading) {
Button("Action") {
// ...
}
This worked until iPadOS 26 introduced new window controls (minimize/close) in that corner, which now overlap my button.
In the WWDC Session Video https://developer.apple.com/videos/play/wwdc2025/208/?time=298, they show adapting via .toolbar, but using .toolbar forces me to embed my view in a NavigationStack, which I don’t want. I really only want to add this single button, without converting the whole view structure.
Constraints:
No use of .toolbar (as it compels a NavigationStack).
Keep existing layout—just one overlayed button.
Support automatic adjustment for the new window controls across all window positions and split-screen configurations.
What I’m looking for:
A way to detect or read the system′s new window control safe area or layout region dynamically on iPadOS 26.
Use that to offset my custom button—without adopting .toolbar.
Preferably SwiftUI-only, no heavy view hierarchy changes.
Is there a recommended API or SwiftUI technique to obtain the new control’s safe area (similar to a custom safeAreaInset for window controls) so I can reposition my overlayed button accordingly—without converting to NavigationStack or using .toolbar?
I have two overlay views on each side of a horizontal scroll. The overlay views are helper arrow buttons that can be used to scroll quickly. This issue occurs when I use either ZStack or .overlay modifier for layout. I am using accessibilitySortPriority modifier to maintain this reading order.
Left Overlay View
Horizontal Scroll Items
Right Overlay View
When voiceover is on and i do a single tap on views, the focus shifts to particular view as expected. But for the trailing overlay view, the focus does not shift to it as expected. Instead, the focus goes to the scroll item behind it.
I am trying to create a user flow where I can guide the user how to navigate through my app. I want to add a tip on a TabView that indicates user to navigate to a specific tab. I have seen this work with iOS properly but I am a little lost as VisionOS is not responding the same for .popoverTip etc. Any guidance is appreciated!
I'm a novice in RealityKit and ARKit. I'm using ARKit in SwiftUI to show a cube with a number as shown below.
import SwiftUI
import RealityKit
import ARKit
struct ContentView : View {
var body: some View {
return ARViewContainer()
}
}
#Preview {
ContentView()
}
struct ARViewContainer: UIViewRepresentable {
typealias UIViewType = ARView
func makeUIView(context: UIViewRepresentableContext<ARViewContainer>) -> ARView {
let arView = ARView(frame: .zero, cameraMode: .ar, automaticallyConfigureSession: true)
arView.enableTapGesture()
return arView
}
func updateUIView(_ uiView: ARView, context: UIViewRepresentableContext<ARViewContainer>) {
}
}
extension ARView {
func enableTapGesture() {
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap(recognizer:)))
self.addGestureRecognizer(tapGestureRecognizer)
}
@objc func handleTap(recognizer: UITapGestureRecognizer) {
let tapLocation = recognizer.location(in: self) // print("Tap location: \(tapLocation)")
guard let rayResult = self.ray(through: tapLocation) else { return }
let results = self.raycast(from: tapLocation, allowing: .estimatedPlane, alignment: .any)
if let firstResult = results.first {
let position = simd_make_float3(firstResult.worldTransform.columns.3)
placeObject(at: position)
}
}
func placeObject(at position: SIMD3<Float>) {
let mesh = MeshResource.generateBox(size: 0.3)
let material = SimpleMaterial(color: UIColor.systemRed, roughness: 0.3, isMetallic: true)
let modelEntity = ModelEntity(mesh: mesh, materials: [material])
var unlitMaterial = UnlitMaterial()
if let textureResource = generateTextResource(text: "1", textColor: UIColor.white) {
unlitMaterial.color = .init(tint: .white, texture: .init(textureResource))
modelEntity.model?.materials = [unlitMaterial]
let id = UUID().uuidString
modelEntity.name = id
modelEntity.transform.scale = [0.3, 0.1, 0.3]
modelEntity.generateCollisionShapes(recursive: true)
let anchorEntity = AnchorEntity(world: position)
anchorEntity.addChild(modelEntity)
self.scene.addAnchor(anchorEntity)
}
}
func generateTextResource(text: String, textColor: UIColor) -> TextureResource? {
if let image = text.image(withAttributes: [NSAttributedString.Key.foregroundColor: textColor], size: CGSize(width: 18, height: 18)), let cgImage = image.cgImage {
let textureResource = try? TextureResource(image: cgImage, options: TextureResource.CreateOptions.init(semantic: nil))
return textureResource
}
return nil
}
}
I tap the floor and get a cube with '1' as shown below.
The background color of the cube is black, I guess. Where does this color come from and how can I change it into, say, red? Thanks.
I have an AppIntent that edits an object in my app. The intent accepts an app entity as a parameter, so if you run the intent it will ask which one do you want to edit, then you select one from the list and it shows a dialog that it was edited successfully. I use this same intent in my Home Screen widget initializing it with an objectEntity. The code needs to run in the app's process, not the widget extension process, so the file is added to both targets and it conforms to ForegroundContinuableIntent, and that is supposed to ensure it always runs in the app process. This works great when run from the Shortcuts app and when involved via a button in the Home Screen widget, exactly as expected. Here is that app intent:
@available(iOS 17.0, *)
struct EditObjectIntent: AppIntent {
static let title: LocalizedStringResource = "Edit Object"
@Parameter(title: "Object", requestValueDialog: "Which object do you want to edit?", inputConnectionBehavior: .connectToPreviousIntentResult)
var objectEntity: ObjectEntity
init() {
print("INIT")
}
init(objectEntity: ObjectEntity) {
self.objectEntity = objectEntity
}
@MainActor
func perform() async throws -> some IntentResult & ReturnsValue<ObjectEntity> & ProvidesDialog {
// Edit the object from objectEntity.id...
return .result(value: objectEntity, dialog: "Done")
}
}
@available(iOS 17.0, *)
@available(iOSApplicationExtension, unavailable)
extension EditObjectIntent: ForegroundContinuableIntent { }
I now want to create a ControlButton that uses this intent:
struct EditObjectControlWidget: ControlWidget {
var body: some ControlWidgetConfiguration {
StaticControlConfiguration(kind: "EditObjectControlWidget") {
ControlWidgetButton(action: EditObjectIntent()) {
Label("Edit Object", systemImage: "pencil")
}
}
}
}
When I add the button to Control Center and tap it (on iOS 18), init is called 3x in the app process and 2x in the widget process, yet the perform function is not invoked in either process. No error appears in console logs for the app's process, but this appears for the widget process:
LaunchServices: store <private> or url <private> was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
Attempt to map database failed: permission was denied. This attempt will not be retried.
Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=72, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
What am I doing wrong here? Thanks!
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
iOS
SwiftUI
WidgetKit
App Intents
I have a regular SwiftUI View embedded inside of a NavigationStack. In this view, I make use of the .searchable() view modifier to make that view searchable. I have a button on the toolbar placed on the .confirmationAction section, which is a problem when a User types into the search bar and the button gets replaced by the SearchBar's cancel button.
Thus, I conditionally place the button, depending on whether a User is searching, either on the navigationBar or on the keyboard. The latter does not work however, as the button does not show and when trying to debug the View Hierarchy, Xcode throws an error saying the View Hierarchy could not be displayed. If I set the button to be on the .bottomBar instead, it shows up perfectly and the View Hierarchy also displays with no further issue.
Has someone come across this issue and if so, how did you get it fixed?
Thank you in advance.
On Apple Watch, I have used toolbarForegroundStyle view modifier to change the color of the navigation title programmatically to offer theming support for users.
In watchOS 26 it no longer seem to have any effect. For example with
.toolbarForegroundStyle(.blue, for: .navigationBar)
the title color still uses the AccentColor from the Assets catalog.
Is there any other setup required to get this working, or is it a bug?
Filed a feedback FB18527395
There are several ways we are supposed to be able to control a11y (accessibility) focus in FKA (Full Keyboard Access) mode.
We should be able to set up an @AccessibilityFocusState variable that contains an enum for the different views that we want to receive a11y focus. That works from VO (VoiceOver) but not from FKA mode. See this sample project on Github:
https://stackoverflow.com/questions/79067665/how-to-manage-accessibilityfocusstate-for-swiftui-accessibility-keyboard
Similarly, we are supposed to be able to use accessibilitySortPriority to control the order that views are selected when a user using FKA tabs between views. That also works from VO but not from FKA mode. In the sample code below, the `.accessibilitySortPriority() ViewModifiers cause VO to change to a non-standard order when you swipe between views, but it has no effect in FKA mode.
Is there a way to either set the a11y focus or change the order in which the views are selected that actually works in SwiftUI when the user is in FKA mode?
Code that should cause FKA to tab between text fields in a custom order:
struct ContentView: View {
@State private var val1: String = "val 1"
@State private var val2: String = "val 2"
@State private var val3: String = "val 3"
@State private var val4: String = "val 4"
var body: some View {
VStack {
TextField("Value 1", text: $val1)
.accessibilitySortPriority(3)
VStack {
TextField("Value 2", text: $val2)
.accessibilitySortPriority(1)
}
HStack {
TextField("Value 3", text: $val3)
.accessibilitySortPriority(2)
TextField("Value 4", text: $val4)
.accessibilitySortPriority(4)
}
}
.padding()
}
}```
Don’t over-engineering! No suggested architecture for SwiftUI, just MVC without the C.
On SwiftUI you get extra (or wrong) work and complexity for no benefits. Don’t fight the system.
Before visionOS Beta 4 it was possible to define the launch size in the Info.plist using PreferredLaunchSize like so:
<key>UILaunchPlacementParameters</key>
<dict>
<key>PreferredLaunchSize</key>
<dict>
<key>Height</key>
<integer>750</integer>
<key>Width</key>
<integer>750</integer>
</dict>
</dict>
In visionOS Beta 4 this now doesn't work anymore and the window opens in a 16:9 format and then will scale down to the .defaultSize of the WindowGroup with an animation.
Settings, Notes, Safari still open with a different default size though, including the launch screen.
How are we supposed to do this now?
Unexpected SwiftUI Transaction Behavior
This minimal example demonstrates an unexpected behavior in SwiftUI's Transaction API:
var transaction = Transaction(animation: .none)
transaction.addAnimationCompletion { print("This should not be called!") }
The Issue
The completion handler is called immediately after creation, even though the transaction was never used in any SwiftUI animation context (like withTransaction or other animation-related APIs).
Expected vs Actual Behavior
Expected: The completion handler should only be called after the transaction is actually used in a SwiftUI animation.
Actual: The completion handler is called right after creation, regardless of whether the transaction is used or not.
Current Workaround
To avoid this, I'm forced to implement defensive programming: only creating transactions with completion handlers at the exact moment they're going to be used. This adds unnecessary complexity and goes against the intuitive usage of the Transactions API.
Previously, I sorted my FetchResult in a TableView like this:
@FetchRequest(
sortDescriptors: [SortDescriptor(\.rechnungsDatum, order: .forward)],
predicate: NSPredicate(format: "betragEingang == nil OR betragEingang == 0")
)
private var verguetungsantraege: FetchedResults<VerguetungsAntraege>
...
body
...
Table(of:VerguetungsAntraege.self, sortOrder: $verguetungsantraege.sortDescriptors) {
TableColumn("date", value:\.rechnungsDatum) { item in
Text(Formatters.dateFormatter.string(from: item.rechnungsDatum ?? Date()) )
}
.width(120)
TableColumn("rechNrKurz", value:\.rechnungsNummer) { item in
Text(item.rechnungsNummer ?? "")
}
.width(120)
TableColumn("betrag", value:\.totalSum ) {
Text(Formatters.currencyFormatter.string(from: $0.totalSum as NSNumber) ?? "kein Wert")
}
.width(120)
TableColumn("klient") {
Text(db.getKlientNameByUUID(id: $0.klient ?? UUID(), moc: moc))
}
} rows: {
ForEach(Array(verguetungsantraege)) { antrag in
TableRow(antrag)
}
}
There seem to be changes here in Xcode 26. In any case, I always get the error message in each line with TableColumn("title", value: \.sortingField)
Ambiguous use of 'init(_:value:content:)'
Does anyone have any idea what's changed? Unfortunately, the documentation doesn't provide any information.
Summary
When using .tabViewBottomAccessory in SwiftUI and conditionally rendering it based on the selected tab, the app crashes with a NSInternalInconsistencyException related to _bottomAccessory.displayStyle.
Steps to Reproduce
Create a SwiftUI TabView using a @SceneStorage selectedTab binding.
Render a .tabViewBottomAccessory with conditional visibility tied to selectedTab == .storage.
Switch between tabs.
Return to the tab that conditionally shows the accessory (e.g., “Storage”).
Expected Behavior
SwiftUI should correctly add, remove, or show/hide the bottom accessory view without crashing.
Actual Behavior
The app crashes with the following error:
Environment
iOS version: iOS 26 seed 2 (23A5276f)
Xcode: 26
Swift: 6.2
Device: iPhone 12 Pro
I have opened a bug report with the FB number: FB18479195
Code Sample
import SwiftUI
struct ContentView: View {
enum TabContent: String {
case storage
case recipe
case profile
case addItem
}
@SceneStorage("selectedTab") private var selectedTab: TabContent = .storage
var body: some View {
TabView(selection: $selectedTab) {
Tab(
"Storage", systemImage: "refrigerator", value: TabContent.storage
) {
StorageView()
}
Tab(
"Cook", systemImage: "frying.pan", value: TabContent.recipe
) {
RecipeView()
}
Tab(
"Profile", systemImage: "person", value: TabContent.profile
) {
ProfileView()
}
}
.tabBarMinimizeBehavior(.onScrollDown)
.tabViewBottomAccessory {
if selectedTab == .storage {
Button(action: {
}) {
Label("Add Item", systemImage: "plus")
}
}
}
}
}