import AVFoundation var bombSoundEffect: AVAudioPlayer? func playSound(note: String) { let path = Bundle.main.path(forResource: note+".wav", ofType:nil)! let url = URL(fileURLWithPath: path) do { bombSoundEffect = try AVAudioPlayer(contentsOf: url) bombSoundEffect?.play() } catch { // couldn't load file :( } }