ios - Weird error while trying to play .mp3 sound effects in xcode? -
i trying code simplest 'press button hear sound' setup in xcode possible, , still managing cryptic errors. here code:
in .h file:
#import <avfoundation/avfoundation.h>
in .m file:
- (ibaction)beepbutton:(uibutton *)sender { nsurl* musicfile = [nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"buttonbeep" oftype:@"mp3"]]; avaudioplayer *click = [[avaudioplayer alloc] initwithcontentsofurl:musicfile error:nil]; [click play]; //[click release]; }
when try compile app, errors:
undefined symbols architecture armv7s: "_objc_class_$_avaudioplayer", referenced from: objc-class-ref in myfirstviewcontroller.o ld: symbol(s) not found architecture armv7s clang: error: linker command failed exit code 1 (use -v see invocation)
am doing wrong? appreciated!
this called linker error. done after compiled ok.
the problem symbol _objc_class_$_avaudioplayer
. ignore part through dollar sign leaving avaudioplayer
.
since trying use avaudioplayer
class , import <avfoundation/avfoundation.h>
need realize must include avfoundation.framework
in project.
if @ reference docs avaudioplayer
, see docs state in avfoundation.framework
. how know need add project.
Comments
Post a Comment