Click Sound for a Button

How can I make a click sound when a button (not a keyboard button, a Button button) is tapped?

Are you using UIKit or SwiftUI?

SwiftUI. I keep forgetting to mention that.

Does this help?

Thanks for the link. Seems like a lot of work just to make a click sound, but I’ll give it a try.

It’s because you’re accessing AVFoundation.

The way this video does it isn’t 100% the best way, but it works.

In the 14 day challenge Chris plays sound for the match game, you can use that same template and apply it to SwiftUI

OK, thanks for the info. I’ll give it a try when I get a chance and let you know how it went.

Got it working. The only glitch is that the first click is delayed, probably because it’s loading some code the first time it’s used. I can probably get around that by playing a nothing sound when the app starts.

Thanks for the help.