2 errors when calling AudioServicesPlaySystemSound?

I am creating an application that vibrates when the timer reaches a certain limit.

However, when called

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 

Xcode contains two errors:

 Undefined symbols for architecture i386: "_AudioServicesPlaySystemSound", referenced from: -[drawGraph drawRect:] in drawGraph.o ld: symbol(s) not found for architecture i386 

and

 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

Any ideas on what causes these errors?

+4
source share
1 answer

enter image description here

Unless you just need to add header files as shown above, a framework should be added to the project. and you need the following heading. #import <AudioToolbox/AudioToolbox.h>

  • In Xcode, click the project file at the top of the Project Navigator.

  • Click "YourProjectName" under "Goals"

  • Click the Build Phases tab.

  • Click the plus button in the Link Binaries to Libraries window.

  • Add AudioToolbox.Framework library

  • Add #import <AudioToolbox/AudioToolbox.h>

enter image description here

+27
source

All Articles