My iOS app wants to play a local audio file. So, in xCode, I’ve added a file "audio.m4a" to my project. It resides on the top level of the file tree, but
NSURL *audioFileURL = [[NSBundle mainBundle]
URLForResource:@"audio"
withExtension:@"m4a"];
returns nil
. There must be a stupid oversight. What am I doing wrong?
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *myFile = [mainBundle pathForResource: @"audio" ofType: @"m4a"];
NSURL *audioFileURL = [NSURL URLWithString:myFile];
and check whether that file present in Build Phases" -> "copy bundle Resources"