I'm trying to use this class as
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];
And getting this compiler error
error: AVAudioPlayer.h no such file or directory
I have added #import "AVAudioPlayer.h
at the beginning of the .m
file
Could you let me know how can I fix it?
Thanks
Instead of
#import "AVAudioPlayer.h"
Try
#import <AVFoundation/AVAudioPlayer.h>
Add the AVFoundation framework to your project.
The problem is in the fact that as the Fistman said, you probably did not add the Framework to your project. You need to go to the Frameworks folder (in your project tree on the left side, usually just bellow the Resources folder), right click on Frameworks->Add->Existing Frameworks..' and pick AVFoundation from the list. Notice that by default XCode will open the frameworks folder of your set Active SDK and so it must be at least OS 2.2 in order to show up (that's the earliest version when apple released it). Once you added the framework, it should compile and link and you wouldn't have to add the h files manually.
Hope it helped, -Adi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With