Overview
Tapping on ShareLink crashes the app when ShareLink is added in the toolbar with the placement of secondaryAction
Feedback
FB21337385
Note: Apple engineers please priorities this is a blocker and affects production apps and prevents us from going live.
Environment
Xcode: 26.2 (17C52)
iOS: 26.2
iPadOS: 26.2
Reproduce
Able to reproduce 100% both on Simulator and Device
Isolation of the crash
The crash happens only when the ShareLink is used with the placement .secondaryAction
The crash doesn't 'happen when the ShareLink is used with the placement .primaryAction
Code
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
Text("Hello, world!")
.toolbar {
ToolbarItem(placement: .primaryAction) {
Button("Dummy") {
print("dummy")
}
}
// Tapping on share button will cause it to crash
// Crash only happens when the ShareLink is used with placement .secondaryAction
// It doesn't crash when placement is primaryAction
ToolbarItem(placement: .secondaryAction) {
ShareLink(item: "Some string")
}
}
}
}
}
Crash stack trace
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIActivityViewControllerPresentationController: 0x105a3b580>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804f71d0 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x000000018009c094 objc_exception_throw + 72
2 UIKitCore 0x0000000185a5b17c -[UIPopoverPresentationController presentationTransitionWillBegin] + 2712
3 UIKitCore 0x0000000185a65de0 -[UIPresentationController _presentationTransitionWillBegin] + 28
4 UIKitCore 0x0000000185a6523c __80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke + 1928
5 UIKitCore 0x0000000185a633ec __77-[UIPresentationController runTransitionForCurrentStateAnimated:handoffData:]_block_invoke_3 + 296
6 UIKitCore 0x00000001868b2950 -[_UIAfterCACommitBlock run] + 64
7 UIKitCore 0x00000001868b2d64 -[_UIAfterCACommitQueue flush] + 164
8 UIKitCore 0x0000000186354f04 _runAfterCACommitDeferredBlocks + 256
9 UIKitCore 0x0000000186346bec _cleanUpAfterCAFlushAndRunDeferredBlocks + 76
10 UIKitCore 0x0000000186346cb4 _UIApplicationFlushCATransaction + 68
11 UIKitCore 0x0000000186263c48 __setupUpdateSequence_block_invoke_2 + 372
12 UIKitCore 0x000000018582f378 _UIUpdateSequenceRunNext + 120
13 UIKitCore 0x00000001862640a4 schedulerStepScheduledMainSectionContinue + 56
14 UpdateCycle 0x00000002501912b4 _ZN2UC10DriverCore18continueProcessingEv + 80
15 CoreFoundation 0x000000018041a4ac __CFMachPortPerform + 164
16 CoreFoundation 0x0000000180456aa8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
17 CoreFoundation 0x00000001804560c0 __CFRunLoopDoSource1 + 480
18 CoreFoundation 0x0000000180455188 __CFRunLoopRun + 2100
19 CoreFoundation 0x000000018044fcec _CFRunLoopRunSpecificWithOptions + 496
20 GraphicsServices 0x0000000192a669bc GSEventRunModal + 116
21 UIKitCore 0x0000000186348574 -[UIApplication _run] + 772
22 UIKitCore 0x000000018634c79c UIApplicationMain + 124
23 SwiftUI 0x00000001da58d620 $s7SwiftUI17KitRendererCommon33_ACC2C5639A7D76F611E170E831FCA491LLys5NeverOyXlXpFAESpySpys4Int8VGSgGXEfU_ + 164
24 SwiftUI 0x00000001da58d368 $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 180
25 SwiftUI 0x00000001da31b42c $s7SwiftUI3AppPAAE4mainyyFZ + 148
26 ShareLinkSecondaryPlacementDemo.deb 0x0000000104d82b0c $s31ShareLinkSecondaryPlacementDemo0abcdE3AppV5$mainyyFZ + 40
27 ShareLinkSecondaryPlacementDemo.deb 0x0000000104d82bb8 __debug_main_executable_dylib_entry_point + 12
28 dyld 0x0000000104cc53d0 start_sim + 20
29 ??? 0x0000000104ff0d54 0x0 + 4378791252
)
libc++abi: terminating due to uncaught exception of type NSException
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.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi, I faced with the issue on iOS 26.1 with PHPickerViewController. After first selection I save assetIdentifier of PHPickerResult for images.
next time I open the picker I expect to have the images selected based on assetIdentifier
Code:
var config = PHPickerConfiguration(photoLibrary: .shared())
config.selectionLimit = 10
config.filter = .images
config.preselectedAssetIdentifiers = images.compactMap(\.assetID)
let picker = PHPickerViewController(configuration: config)
picker.delegate = self
present(picker, animated: true)
But on iOS 26.1 they aren't selected. On lower iOS version all works fine.
Does anybody faced with similar issue?
Topic:
UI Frameworks
SubTopic:
UIKit
I have installed the latest beta on my iPad , iPadOS 16.1 (20B5050f)
On running in app in Playgrounds that has a TextField, external keyboard input do not seem to be working.
Tapping on the Text field inserts the cursor but no text can be entered on my external keyboard.
(TextEditor field also do not work)
Tested with both a Smart Keyboard and a Magic Keyboard.
The keyboard works to enter the code in playgrounds, so it is not a keyboard connection issue.
Disconnecting the keyboard, the onscreen keyboard is displayed and works correctly.
Is this a Playgrounds issue or an iPadOS 16.1 issue or a compatibility issue with Playgrounds & iPadOS 16.1 ?
import SwiftUI
struct ContentView: View {
@State var field: String = "Test input"
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
TextField("", text: $field)
.frame(height: 100)
}
}
}
I've got a situation where I want the iPad to push an editing view onto the sidebar (like on iPhone) and also display a detail view (no content view). This is working great.
However, I need to determine which item from a List in a NavigationSplitView has been selected and pass this to the detail view (the selection is out of scope).
This works with the List selection parameter, but the item selected is ONLY selected and the child view in the NavigationLink does not get pushed, nor does the detail view get changed.
I either need to figure out a way to capture the selection without the List Selection parameter (Tap Gesture?) or get the navigation to happen even when using the Selection parameter.
I'd appreciate some ideas as I'm a newb just learning SwiftUI.
Topic:
UI Frameworks
SubTopic:
SwiftUI
With iOS 26 there has been a change in behavior with Pickers in the toolbar. The Picker looks expanded unlike other views such as a Button and Menu. See screenshots below. Is this the intended behavior or a bug? (I already submitted a feedback for this at FB19276474)
What Picker looks like in the toolbar:
What Button looks like in the toolbar:
I have a SwiftUI recursive list, created with the (children:) initializer, just like it's shown in the code example here: https://developer.apple.com/documentation/SwiftUI/List#Creating-hierarchical-lists
I would like this tree view to be searchable (i.e a user enters a query into a text field and it searches the entire tree at all levels). Displaying a search result which is not at the top level would require its parents to be programmatically expanded.
How to programmatically expand certain levels of such a list?
With iOS 26.1 we started seeing a bug that only appears on iPhone Air. This bug is visible with simulators too. I have tried so many different ways to fix the issue, but Instruments Profiler is pointing at UIKitCore.
We load a tab bar, when the user attempts to switch a tab, the app hangs and never recovers. It happens right as the animation of the Glass bubble is in progress.
I have tried a UIKit Tab bar, a SwiftUI Tab bar. I tore out AppDelegate and did a direct @main SwiftUI entry for my application. This issue appears with every tab bar instance I try.
I attempted to disable LiquidGlass by utilizing this flag UIDesignRequiresCompatibility in my plist, but the flag seems to be ignored by the system.
I am not sure what else to try. I have a trace file if that is helpful. What else can I upload?
Here is what the code looks like.
struct ContentView: View {
@State private var selectedTab = 2
var body: some View {
TabView(selection: $selectedTab) {
Text("Profile")
.tabItem {
Label("Me", systemImage: "person")
}
.tag(0)
Text("Training")
.tabItem {
Label("Training", systemImage: "calendar")
}
.tag(1)
Text("Home")
.tabItem {
Label("Home", systemImage: "house")
}
.tag(2)
Text("Goals")
.tabItem {
Label("Goals", systemImage: "target")
}
.tag(3)
Text("Coach")
.tabItem {
Label("Coach", systemImage: "person.2")
}
.tag(4)
}
}
}
#Preview {
ContentView()
}
and AppView entry point
import SwiftUI
@main
struct RunCoachApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
The top toolbar looks fine, but in the bottom toolbar, one of the layers is stretched into a capsule shape instead of an ellipse.
Is this intended?
I have a search field and a List of search results. As the user types in the search field, the List is updated with new results. Crucially, with each update, I want to reset the List's scroll position back to the top. To achieve this, I'm using the following .onChange() modifier along with a ScrollViewReader:
.onChange(of: searchQuery) { _, newQuery in
Task {
searchResults = await searchLibrary(for: newQuery)
scrollViewProxy.scrollTo(0, anchor: .top)
}
}
My List uses index-based IDs, so scrolling to 0 should always go to the first item.
The above code works, but crashes if searchResults is empty because there is no item in the List with an ID of 0. (As a side note, it seems rather excessive for the scrollTo() method to trigger a full-on crash just because the ID is not found; I don't think this should be anything more than a warning, or the method should throw an error that can be caught).
To work around this, I added an isEmpty check, so we only attempt the scroll if the array is not empty:
.onChange(of: searchQuery) { _, newQuery in
Task {
searchResults = await searchLibrary(for: newQuery)
if !searchResults.isEmpty {
scrollViewProxy.scrollTo(0, anchor: .top)
}
}
}
However, even with this check, I was seeing rare crashes in production, consistent with a race condition. My guess is that when searchResults is updated, the view is not recreated immediately, so if scrollTo() is called too quickly, the List may not yet be seeing the latest update to the searchResults array.
I figured that I could try to delay the calling of scrollTo() to give the view time to update:
.onChange(of: searchQuery) { _, newQuery in
Task {
searchResults = await searchLibrary(for: newQuery)
if !searchResults.isEmpty {
DispatchQueue.main.async {
scrollViewProxy.scrollTo(0, anchor: .top)
}
}
}
}
However, even with this, I've just received a crash report pointing to the same issue (the first in about four months). I'm not able to reproduce the bug myself – so it definitely seems like a rare race condition, probably relating to the timing of view updates.
I guess, I can insert another isEmpty check before calling scrollTo(), but I'm starting to wonder if it's even possible to guarantee that the item will be in the List when scrollTo() performs its action, and because this is so hard to reproduce, I can't really test any ideas. Does anyone have any idea how (and at what point) the ScrollViewReader reads the view's current state? What's the right way to approach debugging a problem like this?
Moreover, does anyone have any better suggestions about how to handle resetting the List position? The reason I want to do this is because, if the user types, scrolls a bit, and then types some more, the new results appear above the fold where the user can't see them, leading to a confusing experience.
I thought about switching to the newer .scrollPosition() modifier, but that's only iOS 18+ and only for ScrollViews, not Lists.
Cheers!
Topic:
UI Frameworks
SubTopic:
SwiftUI
Using desaturated mode on an image in a widget will break any links or buttons that use the image as their 'label'.
Using the following will just open the app as if there was no link at all - therefore just using the fallback userActivity handler, or any .widgetURL() urls provided.
Link(destination: URL(string: "bug://never-works")!) {
Image("puppy")
.widgetAccentedRenderingMode(.desaturated)
}
The same goes for buttons:
Button(intent: MyDemoIntent()) {
Image("puppy")
.widgetAccentedRenderingMode(.desaturated)
}
I've tried hacky solutions like putting the link behind the image using a ZStack, and disabling hit testing on the image, but they don't work. Anything else to try?
Logged as Feedback #15152620.
When tap the Button quickly in List, the ButtonStyleConfiguration’s isPressed property don't change properly, always false. When using Button in ScrollView, the same error doesn't exist.
When I called the setTabBarHidden method and passed in false, I found in the KVO callback of the tabBar.isHidden property that the value of newValue was true. Why are the values of the two different? Is this a bug?
Here is the debug stack.
Topic:
UI Frameworks
SubTopic:
UIKit
I’m facing an issue in our native iOS app that occurs specifically on iOS 26.1 (not observed on any lower versions). When I update a @State field value, the UI does not reflect the change as expected.
The @State variable updates internally, but the view does not re-render.
This behaviour started after upgrading to iOS 26.1.
Works fine on iOS 26.0 and earlier versions.
Has anyone else encountered this issue or found a workaround? Any insights or suggestions would be greatly appreciated.
I am looking for a way to change the liquid glass background colors on UIBarButtonItems. Setting tintColor does what I want for a bar button item when it is both the default button and it is enabled. But it does not seem to do anything for disabled buttons or non-prominent buttons.
Also, is there a way to apply such a change using a UINavigationBarAppearance or a UIBarButtonItemAppearance?
If I cannot change this liquid glass color, I might need to disable liquid glass on these by setting hidesSharedBackground to true. Is there a way to do this globally within the app (without using UIDesignRequiresCompatibility), or with something like UINavigationBarAppearance or UIBarButtonItemAppearance?
Thank you.
John
Topic:
UI Frameworks
SubTopic:
UIKit
I'm trying to revamp the player into a floating style like Apple music. I use tabViewBottomAccessory with tabBarMinimizeBehavior. At the time, I noticed an issue that tabViewBottomAccessory would not automatically collapse when the scroll area was small (but still exceeded the screen height). tabViewBottomAccessory can only be automatically collapsed when the scroll area is large enough. Below is the simplest demo.
I'm not sure if it's intentional or if it's a bug. Besides, I wonder if we can control it programmatically(expanded/inline)?
struct ContentView: View {
var body: some View {
TabView {
Tab("Numbers", systemImage: "number.circle") {
List {
// 200 works well, but 20 not
ForEach(0..<200) { index in
Text("\(index)")
}
}
}
}
.tabBarMinimizeBehavior(.onScrollDown)
.tabViewBottomAccessory {
HStack {
Text("SwiftUI Demo App")
}
}
}
}
Simple code like
struct ContentView: View {
@Query var items: [Item]
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
causes UI Hierarchy crash, on Simulators, iPhone and Mac
I found no solution but use @State with fetch descriptor.
With iOS 26.1 and beta 26.2, there is a crash seen for _UIButtonBarItemLayout update. Has anyone experienced this crash or has any information on this
Thread 0 name:
Thread 0 Crashed:
0 libobjc.A.dylib 0x000000019daa144c objc_retain + 16
1 UIKitCore 0x00000001a680b184 -[_UIButtonBarItemLayout _updateItemView] + 360
2 UIKitCore 0x00000001a6d5ddcc -[_UIButtonBarItemLayout minimumLayoutWidthGivenMinimumSpaceWidth:] + 28
3 UIKitCore 0x00000001a6d5eeec -[_UIButtonBarItemGroupLayout recalculateLayoutWidthsGivenItemSpaceWidth:] + 304
4 UIKitCore 0x00000001a6d4ca28 -[_UIButtonBar _widthInfoForLayout:] + 188
5 UIKitCore 0x00000001a68093b4 -[_UIButtonBar _layoutBar] + 108
6 UIKitCore 0x00000001a6809328 __42-[_UIButtonBarStackView updateConstraints]_block_invoke + 44
7 UIKitCore 0x00000001a7dbea8c +[UIView(Animation) performWithoutAnimation:] + 76
8 UIKitCore 0x00000001a68092d0 -[_UIButtonBarStackView updateConstraints] + 112
9 UIKitCore 0x00000001a64707e8 -[UIView(AdditionalLayoutSupport) _previousFittingSizeInfo] + 784
10 UIKitCore 0x00000001a6470508 -[UIView(AdditionalLayoutSupport) _previousFittingSizeInfo] + 48
Topic:
UI Frameworks
SubTopic:
UIKit
Hello,
I'm thinking about how to improve my main tvOS app flow, naively I want to do something like this:
import Combine
import SwiftUI
enum AppState {
case login, onboarding, main
}
class AppStateManager {
let appStatePublisher = PassthroughSubject<AppState, Never>()
func updateState(_ appState: AppState)
}
struct tvOSApp: App {
private var appState: AppState = .login
private let appStateManager = AppStateManager()
var body: some Scene {
WindowGroup {
ZStack {
switch appState {
case .login:
LoginView()
case .onboarding:
OnboardingView()
case .main:
MainView()
}
}
.onReceive(appStateManager.appStatePublisher) {
self.appState = $0
}
}
}
}
So basically, MainView, OnboardingView and LoginView would be the main navigation views of my app, and the appStateManager would be a dependency passed to each of these views and allowing me to update the currently displayed view in the app. (of course I could use an Environment object instead for a 100% SwiftUI solution).
I was wondering, however, if there is a better way to do this, instead of switching in a ZStack, maybe with WindowGroup/Window/Scenes?
Thank you for your help!
Fatal Exception: NSInternalInconsistencyException
Cannot remove an observer <WKWebView 0x135137800> for the key path "configuration.enforcesChildRestrictions" from <STScreenTimeConfigurationObserver 0x13c6d7460>, most likely because the value for the key "configuration" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the STScreenTimeConfigurationObserver [class.]
I noticed that on iOS 26, WKWebView registers STScreenTimeConfigurationObserver, Is this an iOS 26 system issue? What should I do?
We have an iOS app running on macOS (not Mac Catalyst). The preferences are in a dedicated UIWindowScene. We don't want this scene to be restored, so when you start the app the preferences shouldn't be visible.
How can we prevent the UIWindowScene restoration?
Alternatively, if we can't prevent it, how can we ensure the main window scene is in front of the preferences window scene on app start?