ios - Can't import AVFoundation.framework, so app can't play music? -
i new xcode, , trying make simple app playing noise upon button being clicked. asked previous quesiton in had error , user's suggested wasn't importing avfoundation.framework. took suggestion , set import statement, error. please see code below:
my .h file:
#import <uikit/uikit.h> @interface firstviewcontroller : uiviewcontroller @property (weak, nonatomic) iboutlet uilabel *sampletext; @end my .m file:
#import "firstviewcontroller.h" #import <avfoundation/avaudioplayer.h> @interface firstviewcontroller () @end @implementation firstviewcontroller @synthesize sampletext = _sampletext; - (ibaction)beep:(uibutton *)sender { nsurl* musicfile = [nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"button1" oftype:@"mp3"]]; avaudioplayer *click = [[avaudioplayer alloc] initwithcontentsofurl:musicfile error:nil]; [click play]; //[click release]; } however, upon building, linker error:
undefined symbols architecture armv7s: "_objc_class_$_avaudioplayer", referenced from: objc-class-ref in firstviewcontroller.o ld: symbol(s) not found architecture armv7s clang: error: linker command failed exit code 1 (use -v see invocation) can please me resolve this? thanks!
you have add avfoundation framework project. click on project @ top of source list on left, select target, go summary pane, , click "+" button under "linked frameworks , libraries".
Comments
Post a Comment