ebaccount
ebaccount

Reputation: 5051

Issue in including AVAudioPlayer

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

Upvotes: 7

Views: 5406

Answers (3)

Johann
Johann

Reputation: 12398

Instead of

#import "AVAudioPlayer.h"

Try

#import <AVFoundation/AVAudioPlayer.h>

Upvotes: 11

Adi
Adi

Reputation: 2073

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

Upvotes: 3

Gordon Childs
Gordon Childs

Reputation: 36072

Add the AVFoundation framework to your project.

Upvotes: 4

Related Questions