Abort trap: 6 (Xcode 12.5 beta 12E5220o)

I've come across an unexpected error during the build process of my AppKit macOS application. I've traced the problem to a selector, but I don't understand why it's happening and why the selector function would cause cascading errors for a wide swath of unrelated files that were building without issue before this occurrence.

Error:

Stored value type does not match pointer operand type! store %swift.bridge* %28, i64* %5, align 8, !dbg !1304  i64in function $s7Musaeum27ApplicationWindowControllerC9onAddBook33_8D55888026A145BCB0F1FE379539A486LLyyF
<unknown>:0: error: fatal error encountered during compilation;

As part of my custom NSToolbar implementation, the action associated with an NSToolbarItem sets the NSButton's action to an @objc selector. For example, this is how the toolbar item is being constructed:

Code Block swift
let image = NSImage(named: Constants.Toolbar.idAddBook)
image!.size = NSSize(width: 20, height: 20)
let button = NSButton(image: image!, target: self, action: #selector(onAddBook))
button.frame = NSRect(origin: .zero, size: CGSize(width: 35, height: 30))
button.isBordered = false
toolbarItem = customToolbarItem(
    itemForItemIdentifier: NSToolbarItem.Identifier.addBook.rawValue,
    label: NSLocalizedString("Add", comment: ""),
    paletteLabel: NSLocalizedString("Add", comment: ""),
    toolTip: NSLocalizedString("tool tip add book", comment: ""),
    itemContent: button
)

I added the stub of the selector function as follows:
Code Block swift
@objc private func onAddBook() {
}

When the function body is empty, no issues, and the project builds correctly. If I add one trivial line as follows, still no problem:

Code Block swift
@objc private func onAddBook() {
     let urls = fileController.selectFile()
}

However, as soon as I add the following line, all hell breaks loose:

Code Block swift
@objc private func onAddBook() {
    let urls = fileController.selectFile()
guard let urls = urls, urls.count > 0 else { return }
}

The surprising thing is that I don't encounter this issue with any of the other selectors I've implemented in different parts of the project performing similar functions. I've tried moving the @objc functions to extensions, to other classes, etc., but they all result in the same outcome.

I'm thoroughly perplexed and can't seem to work around this issue. Any insight/help would be greatly appreciated.
Answered by LucidNonsense in 663005022
🤦🏻‍♂️ The beta Xcode wasn't throwing an error about guard let urls = urls, urls.count > 0 else { return }. When I opened the project in Xcode 12.4, it displayed an inline error message stating: "Definition conflicts with previous value"." Once I correctly named the guard variable, the problem went away.
Accepted Answer
🤦🏻‍♂️ The beta Xcode wasn't throwing an error about guard let urls = urls, urls.count > 0 else { return }. When I opened the project in Xcode 12.4, it displayed an inline error message stating: "Definition conflicts with previous value"." Once I correctly named the guard variable, the problem went away.
Abort trap: 6 (Xcode 12.5 beta 12E5220o)
 
 
Q