.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

“The model used to open the store is incompatible with the one used to create the store”

This is an Xcode error I was getting that took me a little while to figure out — my application would simply die when starting up with no other clues as to what was happening. I have been running through some tutorials on setting up CoreData for an iPhone app I’m working on, and I’ve been jumping between my laptop and desktop at various points, sharing the same project code between them. Turns out that you can’t just change the data model configuration in Xcode and re-run your application (my database had changed between working environments).  You can either version and migrate to your updated data model (which is what you would do in a production app, but gets a bit complicated), or in development, you can simply delete your existing database and have the compiler recreate it.

It was easy enough to figure out the problem through a little Googling, but it took me a while to discover how to actually solve it, at least running on the iPhone simulator. Of course, it makes sense once you figure it out… all you have to do is delete the app from the simulator, the same exact way you delete apps off of a physical iPhone — click and hold the icon until it switches into jiggling edit mode, then click the X button to delete it. So simple, yet maybe not so obvious.  You would logically think that this is something Xcode would do for you, or at least give you the option.

After doing that I was able to simply recompile and run my project with no problem. I like Objective-C so far, but the errors you have to figure out while working through the learning cycle have often been a bit more cryptic than I’m used to from other environments…

EDIT: Well, it seems that another error, Can’t find model for source store, is also solved by the same method of deleting the app from the simulator. I have no idea what caused it though… :?

Filed under: Xcode, iPhone | Comments: Comments Off