I have the following code to play some brief audio, and while it plays on the iOS Simulator, it won't play on a real device.
NSString *fileName = @"some_file_name";
SystemSoundID alertSound;
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:fileName
withExtension:@"wav"];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)fileURL, &alertSound);
AudioServicesPlaySystemSound(alertSound);
It turns out, someone else in my code base was setting
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord]
.
This was causing my audio to be muted. I fixed this by changing AVAudioSessionCategoryRecord
to AVAudioSessionCategoryPlayAndRecord
.