tags:

views:

354

answers:

3

Hi,

I am 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

A: 

fixed by importing AVFoundation/AVFoundation.h. However, I am getting linker error. Could you let me know how to fix that?

ebaccount
+1  A: 

Add the AVFoundation framework to your project.

Rhythmic Fistman
+1  A: 

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

Adi