Using existing system sounds in iOS App [swift|

TheOnlyXan picture TheOnlyXan · Jun 29, 2015 · Viewed 43.5k times · Source

Is it possible to use the existing Apple system sounds in my own app? I would like to write a sample app in Swift that does the following steps:

  1. Read/Get a list of all available systemSounds on the device (I think they are located in /System/Library/Audio/UISounds/)
  2. show the list on the screen
  3. if I touch a list item, play these sound

So its basically the same, like when you choose a new ringtone on your iPhone.

I think some apps are using this sounds, or have they copied/bought it?

Thanks and regards Jens

Answer

Beau Nouvelle picture Beau Nouvelle · Jun 29, 2015

You can use this Swift 5 code to play system sounds:

// import this
import AVFoundation

// create a sound ID, in this case its the tweet sound.
let systemSoundID: SystemSoundID = 1016

// to play sound
AudioServicesPlaySystemSound (systemSoundID)

The most up to date list of sounds I could find are here.

Documentation Reference