iOS simulator version 18.0+
I have a demo like this:
Menu {
Button {
} label: {
Text("Option 1")
Image(systemName: "star")
}
Button {
} label: {
Text("Option 2")
Image(systemName: "star")
}
} label: {
Text("Menu")
}
And I used the tool Accessibility Inspector to modify the text size.
Case 1:
We could see the option title and the star icon.
Case 2:
But we could not see the icon, only the option title here
Is this by design from Apple? Or does this need to be fixed? Does anyone know about my question?
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 have a SwiftUI app. It fetches records through CoreData. And I want to show some records on a widget. I understand that I need to use AppGroup to share data between an app and its associated widget.
import Foundation
import CoreData
import CloudKit
class DataManager {
static let instance = DataManager()
let container: NSPersistentContainer
let context: NSManagedObjectContext
init() {
container = NSPersistentCloudKitContainer(name: "DataMama")
container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group identifier)!.appendingPathComponent("Trash.sqlite"))]
container.loadPersistentStores(completionHandler: { (description, error) in
if let error = error as NSError? {
print("Unresolved error \(error), \(error.userInfo)")
}
})
context = container.viewContext
context.automaticallyMergesChangesFromParent = true
context.mergePolicy = NSMergePolicy(merge: .mergeByPropertyObjectTrumpMergePolicyType)
}
func save() {
do {
try container.viewContext.save()
print("Saved successfully")
} catch {
print("Error in saving data: \(error.localizedDescription)")
}
}
}
// ViewModel //
import Foundation
import CoreData
import WidgetKit
class ViewModel: ObservableObject {
let manager = DataManager()
@Published var records: [Little] = []
init() {
fetchRecords()
}
func fetchRecords() {
let request = NSFetchRequest<Little>(entityName: "Little")
do {
records = try manager.context.fetch(request)
records.sort { lhs, rhs in
lhs.trashDate! < rhs.trashDate!
}
} catch {
print("Fetch error for DataManager: \(error.localizedDescription)")
}
WidgetCenter.shared.reloadAllTimelines()
}
}
So I have a view model that fetches data for the app as shown above.
Now, my question is how should my widget get data from CoreData? Should the widget get data from CoreData through DataManager? I have read some questions here and also read some articles around the world. This article ( https://dev.classmethod.jp/articles/widget-coredate-introduction/ ) suggests that you let the Widget struct access CoreData through DataManager. If that's a correct fashion, how should the getTimeline function in the TimelineProvider struct get data? This question also suggests the same. Thank you for your reading my question.
I've run into a strange issue.
If a sheet loads a view that has a SwiftData @Query, and there is an if statement in the view body, I get the following error when running an iOS targetted SwiftUI app under MacOS 26.1:
Set a .modelContext in view's environment to use Query
While the view actually ends up loading the correct data, before it does, it ends up re-creating the sqlite store (opening as /dev/null).
The strange thing is that this only happens if there is an if statement in the body. The statement need not ever evaluate true, but it causes the issue.
Here's an example. It's based on the default xcode new iOS project w/ SwiftData:
struct ContentView: View {
@State private var isShowingSheet = false
var body: some View {
Button(action: { isShowingSheet.toggle() }) {
Text("Show Sheet")
}
.sheet(isPresented: $isShowingSheet, onDismiss: didDismiss) {
VStack {
ContentSheetView()
}
}
}
func didDismiss() { }
}
struct ContentSheetView: View {
@Environment(\.modelContext) private var modelContext
@Query public var items: [Item]
@State var fault: Bool = false
var body: some View {
VStack {
if fault { Text("Fault!") }
Button(action: addItem) {
Label("Add Item", systemImage: "plus")
}
List {
ForEach(items) { item in
Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))
}
}
}
}
private func addItem() {
withAnimation {
let newItem = Item(timestamp: Date())
modelContext.insert(newItem)
}
}
}
It requires some data to be added to trigger, but after adding it and dismissing the sheet, opening up the sheet with trigger the Set a .modelContext in view's environment to use Query. Flipping on -com.apple.CoreData.SQLDebug 1 will show it trying to recreate the database.
If you remove the if fault { Text("Fault!") } line, it goes away. It also doesn't appear to happen on iPhones or in the iPhone simulator.
Explicitly passing modelContext to the ContentSheetView like ContentSheetView().modelContext(modelContext) also seems to fix it.
Is this behavior expected?
Hello,
I'm having a problem with the .glasseffect modifier in a view of a SwiftUI application. I have a list that starts with a static element, followed by several dynamic entries, and then another static element. I've applied the .glasseffect modifier to all the elements, and it works fine except for the first static element. I think I've figured out what's causing it. This element contains two date pickers, and if I comment one out, it works. As soon as both are present, I get a BAD_ACCESS_ERROR.
Oddly enough, this only happens on the tablet. Everything runs normally in the simulator. If I remove the .glassmodifier and use a normal background, it still works.
Is this a bug, or is it against Liquid Glass to have two date pickers in a stack and then use the .glasseffect modifier?
I was trying to figure out why my bottom sheet looks weird and doesn't have the "proper glass" look. I found that this issue seems to be new to iOS 26.1.
See the images below, they show the same view hierarchy (in this case UIHostingController configured as bottom sheet that has NavigationStack and content.
On iOS 26.1 there seems to be extra two layers of background - even though I am no adding any.
iOS 26:
iOS 26.1
Has anyone experienced something similar? Any workarounds? I am happy to completely disable the glass effect for this bottom sheet if it helps.
The screenshots show one sheet, but the same thing happens for another ones.
Hi everyone,
I’m trying to reproduce the layout Apple Music uses for playlists, where there is header content above the table (artwork, title, buttons), and when you scroll, everything scrolls together—the header and table rows move as a single scrollable region.
Here’s an example of what I’m trying to achieve:
I’m using SwiftUI’s Table view and I haven’t found a clean way to place custom content above the table while keeping everything inside the same scroll view.
Is there currently a recommended way to achieve Apple Music–style scrollable header + table content using SwiftUI?
Thanks!
For information I stumbled upon a regression with SwiftUI Slider on iOS 26. Its onEditingChanged closure might be called twice when interaction ends, with a final Boolean incorrect value of true provided to the closure.
As a result apps cannot reliably rely on this closure to detect when an interaction with the slider starts or ends.
I filed a feedback under FB20283439 (iOS 26.0 regression: Slider onEditingChanged closure is unreliable).
Hello,
in my widget the user displays images filling the whole widget with overlayed texts (via ZStack). Via shadows or text background color the text gets better readable.
However, when a user chooses transparent or tinted colors for the home screen, the text is barely or not readable anymore since e.g. white text on white image background. How to resolve this issue?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
SwiftUI
Visual Design
WidgetKit
What is the correct way to implement scrolling in a looong list that uses ScrollView and LazyVstack
Imagine I have some api that returns a longs list of comments with replies
The basic usecase is to scroll to the bottom(to the last comment) Most of the time this works fine
But, imagine some of the comments have many replies like 35 or more (or even 300)
User expands replies for the first post, then presses scroll to bottom.
The scrollbar reaches the bottom and I see the blank screen.
Sometimes the scrollbar may jump for a while before lazyvstack finishes loading or until I manually scroll up a bit or all the way up and down
What should I do in this case? Is this the swiftui performance problem that has no cure?
Abstract example:
ScrollViewReader { proxy in
ScrollView {
LazyVStack {
ForEach(comments) { comment in
CommentView(comment: comment)
.id("comment-\(comment.id)")
}
}
}
}
struct CommentView: View {
let comment: Comment
@State var isExpanded = false
var body: some View {
VStack {
Text(comment.text)
if isExpanded {
RepliesView(replies: comment.replies) // 35-300+ replies
}
}
}
}
...
scroll
proxy.scrollTo("comment-\(lastComment.id)", anchor: .bottom)
Is anyone else experiencing NavigationStack title disappearing in iOS 26?
Hey everyone,
I just updated to iOS 26 and I'm running into a really frustrating issue with my app. Wondering if anyone else is seeing this or if I'm missing something obvious.
What's happening:
My navigation titles are completely blank when the app first loads, but then magically appear when I scroll down. It's super weird and makes my app look broken at first glance.
My setup:
I'm using NavigationStack with some pretty standard stuff:
Navigation title with .navigationTitle()
A toolbar with a settings button
ScrollView content with a gradient background
Here's basically what I have:
NavigationStack {
ScrollView {
VStack(spacing: 24) {
// My app content here - cards, etc.
ForEach(myItems) { item in
// Content cards
}
}
.padding()
}
.background(
LinearGradient(
gradient: Gradient(colors: [
Color.surfacePrimary,
Color.surfacePrimary.opacity(0.95),
Color.surfaceSecondary.opacity(0.3)
]),
startPoint: .top,
endPoint: .bottom
)
)
.navigationTitle("My Title") // ← This doesn't show up initially!
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button("Settings") {
// Settings action
}
}
}
}
The weird part:
Works perfectly fine on my iOS 18.6.2 device
Completely broken on iOS 26 - blank navigation area
As soon as I scroll, the title appears and stays there
Happens on both simulator and physical device
What I've tried:
Double-checking my code (it's identical to what worked before)
Testing on multiple devices
Different navigation title strings
Removing and re-adding the toolbar
Has anyone else run into this? I'm thinking it might be an iOS 26 bug with NavigationStack, but I wanted to check if others are seeing it before filing a radar.
It's affecting my main landing screens (Tennis, NFL, and Prediction Markets tabs) and honestly looks pretty bad when users first open the app and see blank headers.
Temporary fix I found:
If anyone else hits this, I discovered that forcing inline titles works as a workaround:
.navigationTitle("My Title")
.navigationBarTitleDisplayMode(.inline) // This fixes it but kills large titles
Obviously not ideal since we lose the nice large title behavior, but at least the titles show up.
Questions:
Is this happening to anyone else's iOS 26 apps?
Any better workarounds that preserve large titles?
Should I file this as a radar or is Apple already aware?
Really hoping this gets fixed soon - having to choose between broken navigation or losing large titles is pretty frustrating.
Thanks for any insights!
Anyone else dealing with this NavigationStack nightmare in iOS 26? 😅
Our app was just rejected by Apple because they say the subscription management sheet never loads. It just spins indefinitely.
We're using StoreKit's manageSubscriptionsSheet view modifier to present the sheet, and it's always worked for us when testing in SandBox.
Has anyone else had this problem?
Given that it's Apple's own code that got us rejected, what's our path forward?
I understand this is a known issue, but it’s truly unacceptable that it remains unresolved. Allowing users to customize toolbars is a fundamental macOS feature, and it has been broken since the release of macOS 15.
How is it possible that this issue persists even in macOS 15.3 beta (24D5040f)?
FB15513599
import SwiftUI
struct ContentView: View {
@State private var showEditItem = false
var body: some View {
VStack {
VStack {
Text("Instructions to reproduce the crash")
.font(.title)
.padding()
Text("""
1. Click on "Toggle Item"
2. In the menu go to File > New Window
3. In new window, click on "Toggle Item"
""")
}
.padding()
Button {
showEditItem.toggle()
} label: {
Text("Toggle Item")
}
}
.padding()
.toolbar(id: "main") {
ToolbarItem(id: "new") {
Button {
} label: {
Text("New…")
}
}
if showEditItem {
ToolbarItem(id: "edit") {
Button {
} label: {
Text("Edit…")
}
}
}
}
}
}
[Also submitted as FB20225387]
When using a custom SF Symbol that combines a base symbol with a badge, the symbol doesn’t stay vertically centered when displayed in code. The vertical alignment shifts based on the Y offset of the badge.
There are two problems with this:
The base element shouldn’t move vertically when a badge is added—the badge is meant to add to the symbol, not change its alignment.
The badge position should be consistent with system-provided badged symbols, where badges always appear in a predictable spot relative to the corner they're in (usually at X,Y offsets of 90% or 10%).
Neither of these behaviors match what’s expected, leading to inconsistent and misaligned symbols in the UI.
Screenshot of Problem
The ellipsis shifts vertically whenever the badge Y offset is set to anything other than 50%. Even at a 90/10 offset, it still doesn’t align with the badge position of the system "envelope.badge" symbol.
SF Symbols Export
This seem to be a SwiftUI issue since both the export from SF Symbols is correctly centered:
Xcode Assets Preview
And it's also correct in the Xcode Assets preview:
Steps to Repro
In SF Symbols, create a custom symbol of "ellipsis" (right-click and Duplicate as Custom Symbol)
Combine it with the "badge" component (select Custom Symbols, select the newly-created "custom.ellipsis", then right-click and Combine Symbol with Component…)
Change the badge's Y Offset to 10%.
Export the symbol and add it to your Xcode asset catalog.
In Xcode, display the symbol inside a Button using Image(“custom.ellipsis.badge”).
Add a couple more buttons separated by spacers, using system images of "ellipsis" and "app.badge".
Compare the "custom.ellipsis.badge" button to the two system symbol buttons.
Expected
The combined symbol remains vertically centered, matching the alignment shown in both the SF Symbols export window and the Xcode asset catalog thumbnails.
Actual
The base symbol (e.g., the ellipsis portion) shifts vertically based on the Y offset of the badge element. This causes visual misalignment when displayed in SwiftUI toolbars or other layouts. Also included the system “envelope.badge” icon to show where a 90%, 10% badge offset should be located.
System Info
SF Symbols Version 7.0 (114)
Xcode Version 26.0 (17A321)
macOS 15.6.1 (24G90)
iOS 26.0 (23A340)
Noticed when using .glassEffect within NavigationStack gives different result when interacting with view.
When it is not in NavigationStack, when view pressed, glassEffect is within Capsule, clipped.
But when used with NavigationStack, pressing view gives additional background effect in rectangle form.
In image can see this effect, it is subtle but in other scenarios its much more visible.
Is there a way how to use glassEffect without rectangle appearing in NavigationStack?
Here is full code for this example.
struct ExampleGlass: View {
var body: some View {
GlassObject()
.padding()
.background(.blue)
}
}
struct ExampleGlassNavStack: View {
var body: some View {
NavigationStack {
GlassObject()
.padding()
.background(.blue)
}
}
}
struct GlassObject: View {
var body: some View {
Capsule()
.frame(height: 150)
.glassEffect(.clear.interactive())
}
}
#Preview {
ExampleGlass()
ExampleGlassNavStack()
}
Hi all...
The app I'm building is not really a beginner level test app, it's intended to be published so I want everything to be done properly while I'm both learning and building the app. I'm new to swift ecosystem but well experienced with python and JS ecosystems.
These two models are causing my app to crash
@Model
final class CustomerModel {
var id: String = UUID().uuidString
var name: String = ""
var email: String = ""
var phone: String = ""
var address: String = ""
var city: String = ""
var postalCode: String = ""
var country: String = ""
@Relationship(deleteRule: .nullify)
var orders: [OrderModel]?
@Relationship(deleteRule: .nullify)
var invoices: [InvoiceModel]?
init() {}
}
@Model
final class OrderModel {
var id: String = UUID().uuidString
var total: Double = 0
var status: String = "processing"
var tracking_id: String = ""
var order_date: Date = Date.now
var updated: Date = Date.now
var delivery_date: Date?
var active: Bool = true
var createdAt: Date = Date.now
var items: [OrderItem]?
@Relationship(deleteRule: .nullify)
var invoice: InvoiceModel?
@Relationship(deleteRule: .nullify)
var customer: CustomerModel?
init() {}
}
both referenced in this model:
@Model
final class InvoiceModel{
var id: String = UUID().uuidString
var status: String = "Pending"
var comment: String = ""
var dueDate: Date = Date.now
var createdAt: Date = Date.now
var updated: Date = Date.now
var amount: Double = 0.0
var paymentTerms: String = "Once"
var paymentMethod: String = ""
var paymentDates: [Date] = []
var numOfPayments: Int = 1
@Relationship(deleteRule: .nullify, inverse: \OrderModel.invoice)
var order: OrderModel?
@Relationship(deleteRule: .nullify)
var customer: CustomerModel?
init() {}
}
This is my modelContainer in my index structure:
@main
struct Aje: App {
var appContainer: ModelContainer = {
let schema = Schema([UserModel.self, TaskModel.self, SubtaskModel.self, InventoryModel.self, SupplierModel.self])
let config = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false, allowsSave: true, groupContainer: .automatic, cloudKitDatabase: .automatic)
do{
return try ModelContainer(for: schema, configurations: [config])
}catch{
fatalError("An error has occured: \(error)")
}
}()
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(appContainer)
}
}
This works fine but the below after adding the problematic models crashes the app unless CloudKit is disabled
@main
struct Aje: App {
var appContainer: ModelContainer = {
let schema = Schema([UserModel.self, TaskModel.self, SubtaskModel.self, InventoryModel.self, SupplierModel.self, InvoiceModel.self, OrderModel.self, CustomerModel.self])
let config = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false, allowsSave: true, groupContainer: .automatic, cloudKitDatabase: .automatic)
do{
return try ModelContainer(for: schema, configurations: [config])
}catch{
fatalError("An error has occured: \(error)")
}
}()
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(appContainer)
}
}
Topic:
Developer Tools & Services
SubTopic:
Xcode Cloud
Tags:
Swift Packages
CloudKit
SwiftUI
SwiftData
Hi,
I am trying to add a custom (create) button next to the automatic "toggle sidebar" button in a NavigationSplitView.
When the sidebar is collapsed that button should be displayed in a group with that automatic toggle button.
Basically I want exact the same behaviour as in the Apple "Reminders" App.
How could I archive that?
Thanks for your help :-)
Jan
Returning to a Mac Catalyst app that I put to the side for awhile..when running it on Xcode 26.1 it crashes at launch with:
Assertion failure in -[NSToolbarItemGroupView _layoutWrapperViewsWithAttributes:], NSToolbarItemGroupView.m:599
No attributes were found for item
Call stack has a bunch of Autolayout code in AppKit like:
[NSWindow(NSConstraintBasedLayoutInternal) _layoutViewTree] + 120
50 AppKit 0x00000001911e8a10 -[NSWindow(NSConstraintBasedLayoutInternal) layoutIfNeeded] + 240
51 UIKitMacHelper 0x00000001a98f293c -[UINSWindow layoutIfNeeded] + 56
A few unnamed symbols mixed in maybe that's that Swiftness beneath the surface. App is just murdered on launch. I assume this is related to using NSToolbarItemGroup when building an NSToolbar...
I do see this log out:
NSToolbarItemGroup does not support selectionMode. Create the group with one of the class constructors to support selection.
Which is an interesting log so I commented out all calls to setSelectionMode: but still the same crash.
I do set the groups subitems property directly (I do not use the class constructors as the logging statement above indicates). I have no idea if using the class constructors will workaround this issue or not but I'm not particularly excited about that idea because I have items in the same toolbar group with different actions.
I'm running into an issue where my application will hang when switching tabs. The issue only seems to occur when I include a Swift Chart in a navigation label. The application does not hang If I replace the chart with a text field.
This appears to only hang when running on macOS 26. When running on iOS (simulator) or visionOS (simulator, on-device) I do not observe a hang. The same code does not hang on macOS 15.
Has any one seen this behavior?
The use case is that my root view is a TabView where the first tab is a summary of events that have occurred. This summary is embedded in a NavigationStack and has a graph of events over the last week. I want the user to be able to click that graph to get additional information regarding the events (ie: a detail page or break down of events).
Initially, the summary view loads fine and displays appropriately. However, when I switch to a different tab, the application will hang when I switch back to the summary view tab.
In Xcode I see the following messages
=== AttributeGraph: cycle detected through attribute 162104 ===
=== AttributeGraph: cycle detected through attribute 162104 ===
=== AttributeGraph: cycle detected through attribute 162104 ===
=== AttributeGraph: cycle detected through attribute 162104 ===
=== AttributeGraph: cycle detected through attribute 162104 ===
A simple repro is the following
import SwiftUI
import Charts
@main
struct chart_cycle_reproApp: App {
var body: some Scene {
WindowGroup {
TabView {
Tab("Chart", systemImage: "chart.bar") {
NavigationStack {
NavigationLink {
Text("this is an example of clicking the chart")
}
label: {
Chart {
BarMark(
x: .value("date", "09/03"),
y: .value("birds", 3)
)
// additional marks trimmed
}
.frame(minHeight: 200, maxHeight: .infinity)
}
}
}
Tab("List", systemImage: "list.bullet") {
Text("This is an example")
}
}
}
}
}
In macOS Tahoe, users can tint folders or add symbols. But when trying to access that customized icon in Swift, the system always returns the default folder icon.
NSWorkspace.shared.icon(forFile: url.path)
try url.resourceValues(forKeys: [.effectiveIconKey]).effectiveIcon
try url.resourceValues(forKeys: [.customIconKey]).customIconKey
All of these give back the standard folder icon without any of the user-applied customization.
So the question is: Is there any API or workaround in Swift to retrieve the actual customized folder icon (including tint and symbol) as displayed in Finder on macOS Tahoe?
Unable to open mach-O at path: /AppleInternal/Library/BuildRoots/4~B5FIugA1pgyNPFl0-ZGG8fewoBL0-6a_xWhpzsk/Library/Caches/com.apple.xbs/Binaries/RenderBox/install/TempContent/Root/System/Library/PrivateFrameworks/RenderBox.framework/Versions/A/Resources/default.metallib Error:2
This happens only on macOS Sequoia - not on macOS Tahoe.
I have got a noticeable amount of lag in the animations of my App where this Warning arises
I've tried to isolate the respective animations from the main thread too - still getting the same issue with the lag
Is it possible to resolve it, as I want backwards compatibility with my app for the users