Monday, September 19, 2011

Error "Undefined symbols for architecture i386: _OBJC_CLASS_$_AVAudioPlayer referenced from: objc-class-ref"

Was away on holiday last week. Of course I brought my MacBook Pro with me. Unfortunately there's no Internet access, which is extremely painful...

I was playing around with the Core Animation Demo by Bob McCune and created this very simple sound testing project.

But whenever I tried to compile the project, as below it kept showing this error:
Undefined symbols for architecture i386: _OBJC_CLASS_$_AVAudioPlayer referenced from: objc-class-ref
And without Internet Access I was stuck for the whole week, biting my finger nails, scratching my head, searched through every PDF I have but couldn't workout anything. I wonder was that something Apple put in to encourage developers to sign in to the developer program??

When I finally got Internet today I quickly searched the net and found quite a few people having same issue. I found this post from stackoverflow most relevant. So it's my fault, I didn't add the AVFoundation framework!! Simple as that, but without the Internet I would never be able to work that out for sure as I never seen that error before.

Next question then is how to do that in Xcode 4?

As shown below, click on "TARGETS" in the middle panel, then click on the "Build Phases", expand the "Link Binary With Libraries", then click the "+" sign.

After added the AVFoundation framework it works like a charm!

I love the feeling when I learned new things or fixed some annoying problems!

0 comments:

Post a Comment