Playing system sound without importing your own
Solution 1:
I find this list of systemSoundID very useful for accessing the sound ID directly.
http://iphonedevwiki.net/index.php/AudioServices
For example, to play a key press tock sound.
#define systemSoundID 1104
AudioServicesPlaySystemSound (systemSoundID);
You'll also need to add the AudioToolbox framework in your project, and add #include <AudioToolbox.h>
to your .m or .h file.
Solution 2:
This code plays apple system sound "Tock.aiff"..I believe you can play different system sounds using this
NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
AudioServicesDisposeSystemSoundID(soundID);
See this thread
Apple's documentation on System sounds
https://developer.apple.com/documentation/audiotoolbox/system_sound_services
Solution 3:
You can use this for all default system audio.
Example, for the tap sound user this:
AudioServicesPlaySystemSound(1104);
For positive sounds, use this:
AudioServicesPlaySystemSound(1054);
And, negative sounds use this:
AudioServicesPlaySystemSound(1053);
The complete list you can see here.
Solution 4:
List of all system sounds: iOSSystemSoundsLibrary
After you import AVKit
, you can play all this sounds with:
AudioServicesPlaySystemSound (systemSoundID);