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
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,
Overview
I have a Mac app with a settings window. When I add a button it is added to the center.
I want it on the trailing edge, I even tried adding it as confirmationAction but doesn’t work.
Screenshot
Feedback
FB21374186
Steps to reproduce
Run the project on mac
Open the app's settings by pressing ⌘ ,
Notice that the Save button is in the center instead of the trailing edge
Code
App
import SwiftUI
@main
struct SettingsToolbarButtonBugApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
Settings {
SettingsView()
.frame(width: 300, height: 400)
}
}
}
SettingsView
import SwiftUI
struct SettingsView: View {
var body: some View {
NavigationStack {
Form {
Text("Settings window")
}
.toolbar {
ToolbarItem(placement: .confirmationAction) {
// Save button is the center instead of trailing edge
Button("Save") {}
}
}
.navigationTitle("Settings")
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Problem
On the macOS when Settings view is closed, the @State model is not deallocated
Feedback
FB21393010
Environment
macOS: 26.2 (25C56)
Xcode: 26.2 (17C52)
Steps to reproduce
Run the project
Open app's 'Settings
Look at the console logs
When model is created SettingsModel - init gets printed
When Settings window is closed SettingsModel - deinit is not printed, meaning it is not deallocated
Code
SettingsModel
import SwiftUI
@Observable
class SettingsModel {
init() {
print("SettingsModel - init")
}
deinit {
print("SettingsModel - deinit")
}
}
SettingsView
import SwiftUI
struct SettingsView: View {
@State var model = SettingsModel()
var body: some View {
Text("Settings")
.font(.largeTitle)
.padding(200)
}
}
App
import SwiftUI
@main
struct SettingsBugApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
Settings {
SettingsView()
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Problem
For a mac app, when the Settings view that uses @Environment(\.dismiss) it causes the subview's models to be created multiple times.
Environment
macOS: 26.2 (25C56)
Feedback
FB21424864
Code
App
@main
struct DismissBugApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
Settings {
SettingsView()
}
}
}
ContentView
struct ContentView: View {
var body: some View {
Text("Content")
}
}
SettingsView
struct SettingsView: View {
@Environment(\.dismiss) private var dismiss
var body: some View {
VStack {
Text("Settings")
SectionAView()
}
}
}
SectionAView
struct SectionAView: View {
@State private var model = SectionAViewModel()
var body: some View {
Text("A")
.padding(40)
}
}
SectionAViewModel
@Observable
class SectionAViewModel {
init() {
print("SectionAViewModel - init")
}
deinit {
print("SectionAViewModel - deinit")
}
}
Steps to reproduce (refer to the attached video)
1 - Run the app on the mac
2 - Open app's Settings
3 - Notice the following logs being printed in the console:
SectionAViewModel - init
SectionAViewModel - init
4 - Tap on some other app, so that the app loses focus
5 - Notice the following logs being printed in the console:
SectionAViewModel - init
SectionAViewModel - deinit
6 - Bring the app back to focus
7 - Notice the following logs being printed in the console:
SectionAViewModel - init
SectionAViewModel - deinit
Refer to screen recording
Topic:
UI Frameworks
SubTopic:
SwiftUI
Problem
When a List / Form is added inside a TabView and navigationTitle is set, then switching between tabs causes the navigation title to flicker.
Feedback:
FB21436493
Environment
Xcode: 26.2 (17C52)
iOS: 26.2 (23C55)
Reproducible on: Both simulator and device
Root cause
When List / Form is commented out, issue doesn't occur
Steps to Reproduce
Run app on iOS
Switch between tabs
Notice that the navigation title flickers
Code
ContentView
import SwiftUI
struct ContentView: View {
@State private var selectedTab = TabItem.red
var body: some View {
NavigationStack {
TabView(selection: $selectedTab) {
ForEach(TabItem.allCases, id: \.self) { tab in
Tab(tab.rawValue, systemImage: tab.systemImageName , value: tab) {
// Problem occurs with a List / Form
// Commenting out list works without flickering title
List {
Text(tab.rawValue)
}
}
}
}
.navigationTitle(selectedTab.rawValue)
}
}
}
TabItem
enum TabItem: String, CaseIterable {
case red
case green
case blue
var systemImageName: String {
switch self {
case .red:
"car"
case .green:
"leaf"
case .blue:
"bus"
}
}
}
Screen recording:
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi,
I have created an AppIntent in which there is a parameter called price, I have set the default value as 0.
@Parameter(title: "Price", default: 0)
var price: Int
Problem
When the shortcut is run this parameter is skipped
Aim
I still want to price to be asked however it needs to be pre-filled with 0
Question
What should I do that the shortcut can still ask the price but be pre-filled with 0?