.obj_class_name_* Symbol(s) not found
Yet another needlessly cryptic Xcode compile error I ran into today. Here is the full error:
“.objc_class_name_AVAudioPlayer”, referenced from:
literal-pointer@__OBJC@__cls_refs@AVAudioPlayer in PhoneViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I mean, seriously. What is that supposed to mean? Now, since I had just added some new code for playing a sound in my iPhone application, it was pretty obvious that was the cause, but the error message gave me no clue as to what the actual problem was. Here is the line of code that caused the error:
1 | NSURL *soundURL = [NSURL fileURLWithPath:[mainBundle pathForResource:@"my-sound" ofType:@"caf"]]; |
Pretty straightforward, and copied directly from an Apple sample app. Turns out that even though I was properly importing the AVFoundation framework (required for working with audio/video) in my code, e.g.:
1 | #import <AVFoundation/AVFoundation.h> |
…I had not created a project reference to that library. You do that by right-clicking on the Frameworks folder in the Groups & Files pane in Xcode and choosing “Add… Existing Frameworks…” then selecting the framework(s) you need.
Again, very simple and only something that would trip up a complete n00b like me. I don’t mind a learning curve, but more-helpful error messages would sure make it quicker to overcome these types of issues.
Filed under: Objective-C, Xcode | Comments: Comments Off
Recent Comments