Tapping on ShareLink crashes the app

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

See attached Gif

Tapping on ShareLink crashes the app
 
 
Q