I have never used NSBeep.  I've imported AppKit.framework to the project.  Under Xcode 8.2 with Swift 3, I have
import AppKit
class AppDelegate: NSObject, NSApplicationDelegate {
    func applicationWillFinishLaunching(_ notification: Notification) {
        NSBeep() 
    }
}
And there's no beeping. What am I doing wrong? Thanks.
For Xcode 9.0+, try using NSSound.beep() instead.
Change applicationWillFinishLaunching to applicationDidFinishLaunching. Even better (since some of the other stuff you said is rather weird), start with the built-in template for a Cocoa macOS application and put NSBeep() into the existing applicationDidFinishLaunching implementation. I did that and built-and-ran, and I heard the beep.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With