Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TomCuthill

macrumors newbie
Original poster
Nov 19, 2010
3
0
Hello,

Having a bit of trouble using AVAudioPlayer, when i build and run the application I get the error (Symbol(s) not found) which i can't figure out why. My searches have found nothing relevant.
Code and errors:

Header.
Code:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import "Settings.h"



@interface FinalProjectViewController : UIViewController {
	

	UIButton *myButton;
	AVAudioPlayer *audioPlayer;

}

@property (nonatomic, retain) UIButton *myButton;
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;

-(IBAction) playButtonPressed;
-(IBAction) pauseButtonPressed;

-(IBAction) settingsPressed;
@end

Main.
Code:
#import "FinalProjectViewController.h"

@implementation FinalProjectViewController

@synthesize myButton;
@synthesize audioPlayer;

- (void)viewDidLoad {
    [super viewDidLoad];
	
	NSString *filePath = [[NSBundle mainBundle] pathForResource:@"SecretAgent" ofType:@"mp3"];
	
	NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
	
	audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
	
	[filePath release];
	
	[fileURL release];
	
	[audioPlayer prepareToPlay];
}

-(IBAction) playButtonPressed {
	[audioPlayer play];
	
}
						
-(IBAction) pauseButtonPressed {
	[audioPlayer pause];
							
}
						
						
						
-(IBAction) settingsPressed {
	Settings *myOtherView = [[Settings alloc] init];
	myOtherView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
	[self presentModalViewController:myOtherView animated:YES];
	[myOtherView release];
}	



- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
	[myButton release];
	[audioPlayer release];
}

@end



Error.
Code:
Undefined symbols:
  "_OBJC_CLASS_$_AVAudioPlayer", referenced from:
      objc-class-ref-to-AVAudioPlayer in FinalProjectViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Any help would be appreciated,
Thanks,
Tom
 

NickFalk

macrumors 6502
Jun 9, 2004
347
1
My guess would be that you haven't actually added the AVFoundation/AVFoundation.h framework to your project...(?)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.