Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Activity

A Summary of the WWDC25 Group Lab - UI Frameworks
At WWDC25 we launched a new type of Lab event for the developer community - Group Labs. A Group Lab is a panel Q&A designed for a large audience of developers. Group Labs are a unique opportunity for the community to submit questions directly to a panel of Apple engineers and designers. Here are the highlights from the WWDC25 Group Lab for UI Frameworks. How would you recommend developers start adopting the new design? Start by focusing on the foundational structural elements of your application, working from the "top down" or "bottom up" based on your application's hierarchy. These structural changes, like edge-to-edge content and updated navigation and controls, often require corresponding code modifications. As a first step, recompile your application with the new SDK to see what updates are automatically applied, especially if you've been using standard controls. Then, carefully analyze where the new design elements can be applied to your UI, paying particular attention to custom controls or UI that could benefit from a refresh. Address the large structural items first then focus on smaller details is recommended. Will we need to migrate our UI code to Swift and SwiftUI to adopt the new design? No, you will not need to migrate your UI code to Swift and SwiftUI to adopt the new design. The UI frameworks fully support the new design, allowing you to migrate your app with as little effort as possible, especially if you've been using standard controls. The goal is to make it easy to adopt the new design, regardless of your current UI framework, to achieve a cohesive look across the operating system. What was the reason for choosing Liquid Glass over frosted glass, as used in visionOS? The choice of Liquid Glass was driven by the desire to bring content to life. The see-through nature of Liquid Glass enhances this effect. The appearance of Liquid Glass adapts based on its size; larger glass elements look more frosted, which aligns with the design of visionOS, where everything feels larger and benefits from the frosted look. What are best practices for apps that use customized navigation bars? The new design emphasizes behavior and transitions as much as static appearance. Consider whether you truly need a custom navigation bar, or if the system-provided controls can meet your needs. Explore new APIs for subtitles and custom views in navigation bars, designed to support common use cases. If you still require a custom solution, ensure you're respecting safe areas using APIs like SwiftUI's safeAreaInset. When working with Liquid Glass, group related buttons in shared containers to maintain design consistency. Finally, mark glass containers as interactive. For branding, instead of coloring the navigation bar directly, consider incorporating branding colors into the content area behind the Liquid Glass controls. This creates a dynamic effect where the color is visible through the glass and moves with the content as the user scrolls. I want to know why new UI Framework APIs aren’t backward compatible, specifically in SwiftUI? It leads to code with lots of if-else statements. Existing APIs have been updated to work with the new design where possible, ensuring that apps using those APIs will adopt the new design and function on both older and newer operating systems. However, new APIs often depend on deep integration across the framework and graphics stack, making backward compatibility impractical. When using these new APIs, it's important to consider how they fit within the context of the latest OS. The use of if-else statements allows you to maintain compatibility with older systems while taking full advantage of the new APIs and design features on newer systems. If you are using new APIs, it likely means you are implementing something very specific to the new design language. Using conditional code allows you to intentionally create different code paths for the new design versus older operating systems. Prefer to use if #available where appropriate to intentionally adopt new design elements. Are there any Liquid Glass materials in iOS or macOS that are only available as part of dedicated components? Or are all those materials available through new UIKit and AppKit views? Yes, some variations of the Liquid Glass material are exclusively available through dedicated components like sliders, segmented controls, and tab bars. However, the "regular" and "clear" glass materials should satisfy most application requirements. If you encounter situations where these options are insufficient, please file feedback. If I were to create an app today, how should I design it to make it future proof using Liquid Glass? The best approach to future-proof your app is to utilize standard system controls and design your UI to align with the standard system look and feel. Using the framework-provided declarative API generally leads to easier adoption of future design changes, as you're expressing intent rather than specifying pixel-perfect visuals. Pay close attention to the design sessions offered this year, which cover the design motivation behind the Liquid Glass material and best practices for its use. Is it possible to implement your own sidebar on macOS without NSSplitViewController, but still provide the Liquid Glass appearance? While technically possible to create a custom sidebar that approximates the Liquid Glass appearance without using NSSplitViewController, it is not recommended. The system implementation of the sidebar involves significant unseen complexity, including interlayering with scroll edge effects and fullscreen behaviors. NSSplitViewController provides the necessary level of abstraction for the framework to handle these details correctly. Regarding the SceneDelagate and scene based life-cycle, I would like to confirm that AppDelegate is not going away. Also if the above is a correct understanding, is there any advice as to what should, and should not, be moved to the SceneDelegate? UIApplicationDelegate is not going away and still serves a purpose for application-level interactions with the system and managing scenes at a higher level. Move code related to your app's scene or UI into the UISceneDelegate. Remember that adopting scenes doesn't necessarily mean supporting multiple scenes; an app can be scene-based but still support only one scene. Refer to the tech note Migrating to the UIKit scene-based life cycle and the Make your UIKit app more flexible WWDC25 session for more information.
Topic: UI Frameworks SubTopic: General
0
0
551
Jun ’25
NavigationStack in TabView not working as expected
Hi all! I encountered some strange behaviour that I cannot explain. When I have a NavigationStack that is embedded in a TabView, and that NavigationStack uses a NavigationPath that is stored within an ObservableObject, and the view within the NavigationStack gets its NavigationDestinations via an extension on the View object (either via a direct function or via a ViewExtension), the navigation doesn't work as expected, namely that back button seems to not pop views from the path. Consider the following example: struct ContentView: View { var body: some View { TabView { NavViewContainer1() .tabItem { Text("One") } NavViewContainer2() .tabItem { Text("Two") } } } } @MainActor class Model: ObservableObject { @Published var path = NavigationPath() } struct NavViewContainer1: View { @StateObject private var model = Model() var body: some View { NavigationStack(path: $model.path) { VStack { Text("1").font(.title).padding() NavigationLink(value: "One") { Text("Dest 1") } NavigationLink(value: "Two") { Text("Dest 2") } } .navigationDestination(for: String.self) { Text($0) } } } } struct NavViewContainer2: View { @StateObject private var model = Model() var body: some View { NavigationStack(path: $model.path) { VStack { Text("2").font(.title).padding() NavigationLink(value: "One") { Text("Dest 1") } NavigationLink(value: "Two") { Text("Dest 2") } } .setUpDestinations() } } } extension View { func setUpDestinations() -> some View { navigationDestination(for: String.self) { Text($0) } } } When clicking the destination buttons on the first tab (so in NavViewContainer1, I can go to a child view, back to the root, then click the other link to go to a child view and back to the root, all good. The route taken looks like this: Root > Dest 1 > Root > Dest 2 > Root. However, when I do the same in the second tab (NavViewContainer2), as soon as I click on the second destination, it seems like the first destination was not removed from the path, since clicking the back button in the second destination brings me to the first destination. The route taken looks like this: Root > Dest 1 > Root > Dest 2 > Dest 1 > Root. If I either move the view out of the TabView, move the path inside of the view with a @State variable or as in view 1 add the navigationDestinations directly, the path works as expected. Only the combination of TabView + NavigationPath in ObservableObject + view extension yields this behaviour. Am I missing something here, or is this a bug in the SwiftUI framework?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
284
Oct ’24
External Display with SwiftUI in 2024
What is current best-practice for supporting an external display in a SwiftUI iOS app in 2024? (I'm only interested in iOS 17 and/or iOS 18) The only docs I found require abandoning the SwiftUI App structure and "switching back to a full UIKit App Delegate". Is this still the only option? Are there any complete examples on how to accomplish this? Also is testing external displays with Simulator at all reliable? All experiences I read about say that it never works. Thanks in advance.
0
0
338
Sep ’24
UITextField doesn't apply `keyboardType` on tvOS because of `isSecureTextEntry`
Hello everyone, Recently, I have encountered an issue in my tvOS app where a specific property of UITextField, isSecureTextEntry, set to true, was preventing another property, keyboardType, from functioning correctly. In my case, keyboardType is set to numberPad option. The problem is that during the first tap on the text field, the default keyboard with numbers, letters, and some special characters opens. However, after the second tap, the correct keyboard type with only numbers appears as I want. Removing isSecureTextEntry or setting to false solves the problem. import UIKit class ViewController: UIViewController { private let textField = UITextField() override func viewDidLoad() { super.viewDidLoad() textField.keyboardType = .numberPad textField.isSecureTextEntry = true view.addSubview(textField) setupConstraints() } }
0
0
452
Oct ’24
trailingSwipeActionsConfigurationProvider causes shadow effect on UICollectionViewListCell gone
Currently, I have achieve shadow and corner effect for UICollectionViewListCell, using the following code. UICollectionViewListCell class NoteCell: UICollectionViewListCell { override func awakeFromNib() { super.awakeFromNib() initShadow() initCorner() } private func updateShadowColor() { // Determine the shadow color based on the current interface style let shadowUIColor = UIColor.label self.layer.shadowColor = shadowUIColor.cgColor } private func initShadow() { // https://www.hackingwithswift.com/example-code/uikit/how-to-add-a-shadow-to-a-uiview self.layer.shadowOpacity = 0.3 self.layer.shadowOffset = CGSize(width: 0.5, height: 0.5) self.layer.shadowRadius = 2 self.layer.masksToBounds = false self.updateShadowColor() // Remove the following two lines if you experience any issues with shadow rendering: self.layer.shouldRasterize = true self.layer.rasterizationScale = UIScreen.main.scale } private func initCorner() { var backgroundConfig = UIBackgroundConfiguration.listPlainCell() backgroundConfig.backgroundColor = .systemBackground backgroundConfig.cornerRadius = 16 self.backgroundConfiguration = backgroundConfig } layout private func layoutConfig() -> UICollectionViewCompositionalLayout { let layout = UICollectionViewCompositionalLayout { section, layoutEnvironment in var config = UICollectionLayoutListConfiguration(appearance: .plain) config.headerMode = .none config.footerMode = .none config.showsSeparators = false config.headerTopPadding = 0 config.backgroundColor = nil config.trailingSwipeActionsConfigurationProvider = { [weak self] indexPath in guard let self = self else { return nil } // Knowing what we are tapping at. var snapshot = dataSource.snapshot() let sectionIdentifier = snapshot.sectionIdentifiers[indexPath.section] let itemIdentifiers = snapshot.itemIdentifiers(inSection: sectionIdentifier) let itemIdentifier: NoteWrapper = itemIdentifiers[indexPath.item] let deleteHandler: UIContextualAction.Handler = { action, view, completion in completion(true) // TODO: //snapshot.reloadItems([itemIdentifier]) } let deleteAction = UIContextualAction(style: .normal, title: "Trash", handler: deleteHandler) var swipeActionsConfiguration = UISwipeActionsConfiguration(actions: [ deleteAction, ]) deleteAction.image = UIImage(systemName: "trash") deleteAction.backgroundColor = UIColor.systemRed swipeActionsConfiguration.performsFirstActionWithFullSwipe = false return swipeActionsConfiguration } // https://developer.apple.com/forums/thread/759987 let layoutSection = NSCollectionLayoutSection.list(using: config, layoutEnvironment: layoutEnvironment) layoutSection.interGroupSpacing = 16 // Distance between item. layoutSection.contentInsets = NSDirectionalEdgeInsets( top: 16, // Distance between 1st item and its own header. leading: 16, bottom: 16, // Distance of last item and other header/ bottom edge. trailing: 16 ) return layoutSection } return layout } This is the outcome. However, when I perform swipe action, the shadow effect is gone. Do you have any idea how I can resolve such? Thanks.
0
0
363
Oct ’24
[UITextView becomeFirstResponder] crash with [__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]
I am trying to set my UITextView as the first responder with [self.textView becomeFirstResponder] when my view controller called viewDidAppear. But sometimes it will cause crash with the error: [__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0] all I did is just: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self.textView becomeFirstResponder]; } So if anyone can tell me what happened and how to do? when I call the [self.textView becomeFirstResponder], what will be insert into the responders list? self.textView itself? Thanks very much!
0
0
375
Sep ’24
request review bug
Previously, i create an app and i'm using a userdefault with app group to enable to connect it with extension. But a bug causing me very frustating and so long to solve this, I think it just my code bug, but it was causing by the swiftui itself. Where requestReview environment, causing my navigationlink that pointing to a view that include userdefault that connect to app group is freezing while tapping. Than it just caused in my ios 16 device, and work smoothly in my ios 18 device. struct SettingView: View { @Environment(\.requestReview) var requestReview var body: some View { NavigationStack { List { Section("Configuration") { NavigationLink(destination: WidgetConfigurationView()) { Label("Widget", systemImage: "paintpalette") } } } } } struct WidgetConfigurationView: View { @Environment(\.dismiss) var dismiss @AppStorage("widgetalignment", store: UserDefaults(suiteName: "group.com.my.app")) var alignment: Int = 0 } can anyone explain why this happened? is this my mistake or the swiftui bug?
0
0
325
Oct ’24
NSRuleEditor only allow criterion row to be added once
I have an object that is an NSRuleEditorDelegate for an NSRuleEditor whose nestingMode is NSRuleEditorNestingModeList. There are 8 different possible criteria. Each criterion is optional but at least 1 is required (ruleEditor.canRemoveAllRows = NO). Each criterion should only be added once. How can I limit adding a criterion for a row if it is already in the editor at a different row? Thanks!
0
0
342
Sep ’24
Are SwiftUI Text views with empty strings optimized out in iOS 18?
A UI test case that checks for the existence of a SwiftUI Text element initialized with an empty string previously reliably passed in iOS 17. In iOS 18 the assertion reliably fails. I searched the iOS 18 developer release notes for anything possibly related to this but didn't find much. I'd like to point to a conclusive change in iOS handling before changing the test permantently. Can anyone confirm that this is indeed a change in iOS 18?
0
3
389
Oct ’24
SwiftUI Scroll Issue with Keyboard Type Change
Hello, I'm developing with SwiftUI and have encountered some bug-like behavior that I haven't been able to resolve, so I'm seeking your assistance. I'm building my view using TextEditor, ScrollViewReader, and List, and I've noticed a strange behavior. When the TextEditor at the bottom of the view is focused and the keyboard is displayed, if I change the keyboard type to Emoji and then switch back to the language keyboard, the scroll becomes misaligned. Although the TextEditor remains focused, when this bug occurs, the view's offset is reset as if the focus was lost. Could you help me with this?
0
1
372
Oct ’24
Unable to update NSProgressIndicator for the dock Icon
I have created a progress indicator to simulate some progressing download task in the dock icon. However, I can see the progress bar appearing in the dock icon but it is not getting updated when I invoked the updateProgress() method. Ideally it should have updated it, and I m not able to figure out the reason? I have creating the same NSProgressIndicator on an NSWindow and it works to update the progress bar with the same code. Anything that I m missing to understand here? Below is the code I m using: class AppDelegate: NSObject, NSApplicationDelegate { var progressIndicator: NSProgressIndicator! let dockTile = NSApp.dockTile func applicationWillFinishLaunching(_ notification: Notification) { // Step 1: Create a progress bar (NSProgressIndicator) progressIndicator = NSProgressIndicator(frame: NSRect(x: 10, y: 10, width: 100, height: 20)) progressIndicator.isIndeterminate = false progressIndicator.minValue = 0.0 progressIndicator.maxValue = 100.0 progressIndicator.doubleValue = 0.0 progressIndicator.style = .bar dockTile.contentView = progressIndicator dockTile.display() //// Update the progress bar for demonstration DispatchQueue.main.asyncAfter(deadline: .now() + 1) { self.updateProgress(50) } } func updateProgress(_ value: Double) { progressIndicator.doubleValue = value NSApp.dockTile.display() } }
Topic: UI Frameworks SubTopic: AppKit Tags:
0
0
475
Oct ’24
Split View DoubleColumn Mode
Hi, When SplitView is in detailsOnly and I swipe from left side the sidebar appears as popover above the details content, but when I try to open it manually by settings the columnVisibility to doubleColumn it pushes the details view and shows, so haw to make it appear as poorer ? Kind Regards
Topic: UI Frameworks SubTopic: SwiftUI
0
0
182
Oct ’24
NavigationSplitView(sidebar:content:detail:) does not show View in content closure
View using NavigationSplitView(sidebar:content:detail:) in SwiftUI on tvOS does not show the View in the content closure and does not allow proper navigation. This occurs when NavigationSplitViewStyle is .automatic or .prominentDetail. It also occurs when not specified. You can avoid using this sidebar style by adding .navigationSplitViewStyle(.balanced). However, I would like to build an app employing this View. I would be glad to know what you have noticed and if you have any advice. Code Here is the code to reproduce it Just replace it with this and somehow the phenomenon occurs. import SwiftUI struct ContentView: View { @State var selected:Int? @State var selected2:Int? var body: some View { NavigationSplitView { List(selection: $selected){ NavigationLink(value: 1){ Label("1", systemImage: "1.circle") } NavigationLink(value: 2){ Label("2", systemImage: "2.circle") } NavigationLink(value: 3){ Label("3", systemImage: "3.circle") } } .navigationTitle("Sidebar") } content: { if let selected = selected { List(selection: $selected2){ NavigationLink(value: 1){ Label("1", systemImage: "1.square") } NavigationLink(value: 2){ Label("2", systemImage: "2.square") } NavigationLink(value: 3){ Label("3", systemImage: "3.square") } } .navigationTitle("Content \(selected)") } else { Text("No Selected") } } detail: { Group { if let selected2 = selected2 { Text(String(selected2)) }else{ Text("No Selected") } } .navigationTitle("Detail") .frame(maxWidth: .infinity, maxHeight: .infinity) } .navigationSplitViewStyle(.prominentDetail) } } Environment tvOS 18 Simulator (22J356) macOS 15.1 beta (24B5055e) Xcode 16.0 (16A242d) How to Reproduce Open the attached project with Xcode. Build the project on Apple TV with Xcode. press any button on the sidebar Confirm that the View in the content closure is not displayed. Actual Behavior The View in the content closure is not displayed, and the View in the detail closure is displayed. (4/4) Correct Behavior The View in the content closure is displayed, and when the button of the View is pressed, the View in the detail closure is displayed.
Topic: UI Frameworks SubTopic: SwiftUI
0
1
402
Sep ’24
UICollectionView unwanted content offset change on invalidating layout
I have issue with unwanted changing offset in collection view to top or to near top. It is happening in collection view with vertical scroll when estimatedItemSize is not set to zero (main factor). If estimatedItemSize is zero it is always fine. It is SDK that provides items that should be loaded in few cells, items have dynamic height which is received from server and can be updated several times. Scenario when it happens (when was noticed) is 2 sections, in section 0 item is at index 4 of 14, section 1 is with only one cell with dynamic height item. If specific item is at index 0 in section 0 or have 1 cell per section (tried 15 sections and set items in sections 5 and 15) all is good regardless of estimatedItemSize. When new height is received if I call invalidateLayout or reloadItemAtIndexPaths it will “jump”. That same height is set in sizeForItemAtIndexPath. In some combinations it happens and in some not and that is the most annoying part. I tried setting estimated height to received height and it didn’t help (other cell may be smaller or larger). Also if I put items in one section at indexes 4 and 14 it “jumps”. I managed to make it work by setting at specific moment estimatedItemSize to zero then put back to one that SDK user set and didn’t see any issues but I was wondering if there is any other solution for this and did anyone had issue like this. It would be nice to have solution to keep one estimatedItemSize if it is not the default one (zero).
Topic: UI Frameworks SubTopic: UIKit
0
0
248
Sep ’24
Canvas view crashing with Core Graphics-based drawing
One of my SwiftUI applications using a Canvas view started to crash with Xcode 16. It was working flawlessly with Xcode 15. I was able to come up with a minimal SwiftUI app that shows the issue: @main struct CanvasTest: App { var body: some Scene { WindowGroup { VStack { Canvas { context, size in context.withCGContext { cgContext in let z = Int(size.width / 3.0) for i in 0..<18000 { // crashes from 17413 on cgContext.beginPath() cgContext.move(to: CGPoint(x: (i % z) * 3, y: (i / z) * 2)) cgContext.addLine(to: CGPoint(x: (i % z) * 3 + 2, y: (i / z) * 2)) cgContext.strokePath() } } } } } } } The canvas displays 18000 lines and the context.withCGContext invocation also completes successfully. Yet, the application crashes immediately after like this (details below): Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001800eabb4 Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Terminating Process: exc handler [2162] I was wondering if anyone else noticed that change and found a way to fix it? Alternatively, I am looking for workarounds. I have to be able to display large drawings created via core context-based graphics. Is this worth reporting to Apple? Thanks already now for any help and advice. Hardware Model: Mac15,9 Process: CanvasTest [2162] Path: /Users/USER/Library/Developer/CoreSimulator/Devices/0C372C7C-3D00-48AA-8124-799CB9A35C1E/data/Containers/Bundle/Application/EBAEC7A2-C93D-48B7-9754-4F3F54A33084/CanvasTest.app/CanvasTest Identifier: com.objecthub.CanvasTest Version: 1.0 (1) Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd_sim [98324] Coalition: com.apple.CoreSimulator.SimDevice.0C372C7C-3D00-48AA-8124-799CB9A35C1E [58431] Responsible Process: SimulatorTrampoline [3499] Date/Time: 2024-12-01 14:33:07.7617 +0100 Launch Time: 2024-12-01 14:33:07.4151 +0100 OS Version: macOS 15.1.1 (24B91) Release Type: User Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001800eabb4 Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Terminating Process: exc handler [2162] Triggered by Thread: 0 Application Specific Information: Abort Cause 268435470 Thread 0 Crashed:: Dispatch queue: com.Metal.CommandQueueDispatch 0 libxpc.dylib 0x1800eabb4 _xpc_connection_release_message.cold.1 + 60 1 libxpc.dylib 0x1800c9910 _xpc_connection_release_message + 240 2 libxpc.dylib 0x1800c80b4 _xpc_connection_enqueue + 264 3 libxpc.dylib 0x1800c8b9c xpc_connection_send_message + 128 4 MTLSimDriver 0x2275c6e7c -[MTLSimCommandQueue submitCommandBuffers:count:] + 368 5 Metal 0x19eabdfd4 -[_MTLCommandQueue _submitAvailableCommandBuffers] + 480 6 Metal 0x19eabe4ac __40-[_MTLCommandQueue submitCommandBuffer:]_block_invoke + 24 7 libdispatch.dylib 0x180178de0 _dispatch_client_callout + 16 8 libdispatch.dylib 0x180188ac8 _dispatch_lane_barrier_sync_invoke_and_complete + 92 9 Metal 0x19eabe46c -[_MTLCommandQueue submitCommandBuffer:] + 112 10 MTLSimDriver 0x2275c5fc8 -[MTLSimCommandBuffer commitAndWaitUntilSubmitted] + 40 11 RenderBox 0x1c6e9015c RB::RenderFrame::~RenderFrame() + 240 12 RenderBox 0x1c6e6e9dc __38-[RBLayer displayWithBounds:callback:]_block_invoke.27 + 500 13 libdispatch.dylib 0x180178de0 _dispatch_client_callout + 16 14 libdispatch.dylib 0x180188ac8 _dispatch_lane_barrier_sync_invoke_and_complete + 92 15 RenderBox 0x1c6e6de38 -[RBLayer displayWithBounds:callback:] + 2480 16 RenderBox 0x1c6e6d46c -[RBLayer display] + 172 17 QuartzCore 0x18b0c7e74 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 392 18 QuartzCore 0x18affca50 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464 19 QuartzCore 0x18b02b260 CA::Transaction::commit() + 652 20 UIKitCore 0x185af0f70 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 32 21 CoreFoundation 0x18041b58c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20 22 CoreFoundation 0x18041acc4 __CFRunLoopDoBlocks + 352 23 CoreFoundation 0x1804153cc __CFRunLoopRun + 812 24 CoreFoundation 0x180414c24 CFRunLoopRunSpecific + 552 25 GraphicsServices 0x19020ab10 GSEventRunModal + 160 26 UIKitCore 0x185ad82fc -[UIApplication _run] + 796 27 UIKitCore 0x185adc4f4 UIApplicationMain + 124 28 SwiftUI 0x1d290b41c closure #1 in KitRendererCommon(_:) + 164 29 SwiftUI 0x1d290b144 runApp<A>(_:) + 84 30 SwiftUI 0x1d266bef4 static App.main() + 148 31 CanvasTest.debug.dylib 0x105061c64 static CanvasTest.$main() + 40 32 CanvasTest.debug.dylib 0x105061d14 __debug_main_executable_dylib_entry_point + 12 (CanvasTest.swift:11) 33 dyld_sim 0x10519d410 start_sim + 20 34 dyld 0x10539a274 start + 2840 Thread 4:: com.apple.uikit.eventfetch-thread 0 libsystem_kernel.dylib 0x1050f5290 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x1051066c4 mach_msg2_internal + 76 2 libsystem_kernel.dylib 0x1050fd3f4 mach_msg_overwrite + 536 3 libsystem_kernel.dylib 0x1050f55cc mach_msg + 20 4 CoreFoundation 0x18041b000 __CFRunLoopServiceMachPort + 156 5 CoreFoundation 0x180415528 __CFRunLoopRun + 1160 6 CoreFoundation 0x180414c24 CFRunLoopRunSpecific + 552 7 Foundation 0x180f319c8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 208 8 Foundation 0x180f31be8 -[NSRunLoop(NSRunLoop) runUntilDate:] + 60 9 UIKitCore 0x185b858c0 -[UIEventFetcher threadMain] + 404 10 Foundation 0x180f58810 __NSThread__start__ + 720 11 libsystem_pthread.dylib 0x10507f6f8 _pthread_start + 104 12 libsystem_pthread.dylib 0x10507a940 thread_start + 8
Topic: UI Frameworks SubTopic: SwiftUI
0
0
304
Dec ’24
iOS 18: "Invalid number of items in section 0"
Hi, I recently started experiencing the following bug in the code listed below. The app is a dieting/calorie logging app with a function that presents a List() of calories in different days, separated into sections for each Meal as derived from an array of Meals. Part of this functionality is that the user can swipe an entry in the List to delete one. If the user has one entry and they delete it, behaviour is as expected. If they have more than one entry and they delete one, behaviour is as expected. If they have more than one entry and they delete two items, one after another, the app crashes with the message "Invalid number of items in section 0". If they have more than one entry and they delete one, then go back to the main screen of the app, then delete another one, behaviour is as expected. Searches online suggest that this is because the array underpinning the list has not updated. However the app crashes before it has even reached the delete() function called by onDelete, so there is no opportunity to update the model before something refreshes and the app crashes. Does anyone have any idea how to resolve this? This code worked fine up until iOS 18. List { if list.budgieData.count != 0 { ForEach(list.mealList.indices, id: \.self) { idx in Section(header: Text(list.mealList[idx].name)) { ForEach(list.budgieData.indices, id: \.self) { entryIdx in if list.budgieData[entryIdx].meal == list.mealList[idx].mealUUID { CalorieEntryView(calories: list.budgieData[entryIdx].calories, narrative: list.budgieData[entryIdx].narrative ?? "Quick calories", realEntry: list.budgieData[entryIdx].realEntry, date: list.budgieData[entryIdx].date) } }.onDelete(perform: delete) } } } else { Text("You have no calories logged in Budgie Diet on this day.") } if list.hkCalories != 0 { Section(header: Text("Calories from other apps"), footer: Text("These are calories logged in Health by other apps. You'll need to go to the app that logged them to change or delete them.")) { CalorieEntryView(calories: list.hkCalories, narrative: "Calories from other apps", realEntry: false, date: list.curDate) .deleteDisabled(true) } } }.listStyle(.grouped)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
200
Oct ’24
iOS 18 Icon Display Inconsistency After App Update
Hello Apple Developer Community, I am encountering an issue with app icon rendering after updating an app on devices running iOS 18 or newer. Below are the details: Issue Summary: When updating an app from a previous version (with separate light and dark mode icons) to the latest version (where both modes use the same icon), the icon changes are not reflected consistently across all system menus. Steps to Reproduce: Set the device mode to Dark Mode. Install the previous app version (with different icons for light and dark modes). Update the app to the latest version (where both modes use the same icon). Change the device mode to Light Mode. Switch back to Dark Mode. Expected Behavior: The app icon should remain consistent across all system menus (Home Screen, Spotlight search, etc.) when switching between Light and Dark Modes. Observed Behavior: The app icon displays correctly on the Home Screen but inconsistencies appear in other menus, such as Spotlight search or when toggling between modes. For instance, in Dark Mode, the icon may revert to the previous black-colored logo or display incorrectly compared to the updated design. Additional Notes: The asset catalog is configured correctly, with identical icons set for both light and dark modes in the latest app version. Incrementing the build number was implemented during the update. A manual device restart resolves the issue on some devices, but not consistently. Questions for the Community: Has anyone else experienced similar app icon caching or rendering issues in iOS 18 or later? Are there known workarounds or specific configurations to ensure consistent icon rendering across all system menus? Could this be related to iOS 18's icon caching or appearance handling mechanisms? Your insights and suggestions would be greatly appreciated. Thank you for your time!
0
0
645
Nov ’24
How to fix TINT mode easily since it is iOS 18
To set up iOS 18 widget tint mode without any modifications, follow the steps below. I hope this helps many people. You just need to add one line. .containerBackgroundRemovable(false) ex) struct create_view: Widget { let kind: String = "CalendarWidget" var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider()) { entry in calendar_widgetEntryView(entry: entry) } .supportedFamilies([.systemLarge]) .containerBackgroundRemovable(false) .contentMarginsDisabledIfAvailable() } } Before: After :
0
0
297
Oct ’24
TabView doesn't support scrollClipDisabled
I’m trying to use TabView as a page view, but I’m having some trouble. When I select a tab, the content gets cut off. I tried setting scrollClipDisabled, but that didn’t help. var body: some View { TabView { Button { } label: { AsyncImage( url: URL( string: "https://plus.unsplash.com/premium_photo-1693227521269-d90b70e3ee06?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" ) ) { image in image .resizable() .aspectRatio(contentMode: .fit) } placeholder: { Color.red } } .buttonStyle(.borderless) } .scrollClipDisabled() .tabViewStyle(.page(indexDisplayMode: .always)) .indexViewStyle(.page(backgroundDisplayMode: .always)) Button("Button") { } } If you switch between tab content and the button, you will notice that the bottom corner radius is clipped. Does anyone have any idea how to avoid this action?
0
0
251
Oct ’24