.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

WordPress: Highlight Author Comments

Every time I do a fresh WordPress configuration, one of my first tasks is to customize the comments template to enable highlighting any comments by me to have unique formatting. It also seems that each time I need to set this up, I have to Google how to do it again since it involves getting into the templates and monkeying around with internal PHP code, so this time around I thought I’d document it for myself :) . It would be so nice if WP built this feature into the default template…

Well, apparently they have! And it’s actually been available since version 2.7.0., but it does not appear to be very well publicized (and many custom themes, like the one I’m using, have not been updated to use the new function). Googling for the phrase “wordpress highlight author comments” leads to lots of methods for doing this the old-school ways of modifying template code, or installing special WordPress plugins to achieve comment highlighting. Luckily, I stumbled across this page from the WordPress documentation website that describes the comment_class() function, which automatically outputs a set of CSS class names that provide for just about any comment theming you would need.

If you are using a theme that has not been updated (but you are running WordPress 2.7+), you can modify one line in comments.php like I did so that it will call the new function. Find the loop that outputs the comment blocks, and modify the opening <li> tag code to match this:

1
2
3
4
5
<?php foreach ($comments as $comment) : ?>
    <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
       ...
    </li>
<?php endforeach; ?>

The key is the comment_class() function (which should be defined in the file wp-includes/comment-template.php if your WordPress version is current). This function is called on each iteration, which will give you an extremely useful list of CSS classes in your HTML output. Here’s an example of the output for a comment I wrote:

1
<li class="comment byuser comment-author-admin bypostauthor even thread-even depth-1" id="comment-12">

Wow, that’s a lot of useful classes! The class I’m looking for is bypostauthor, which indicates that it’s a comment I wrote. You could also choose comment-author-admin instead, for a blog by mutliple authors if you wanted any admin of the blog to be highlighted. They’ve even included classes for thread depth, if you’ve configured nested comments — too cool!

While I’m here, I’ll also add a separate style for odd and even rows to get alternating row colors. Doing all of this is simple now, just a few basic CSS rules added to the theme’s main stylesheet:

1
2
3
4
5
6
#comments .even {
    background:#f6f6f6;
}
#comments .bypostauthor {
    background:#E0E8EF;
}

Note that the bypostauthor rule must come after the even rule in the CSS file (in my example at least). Since they both change the same attribute (background color) the second rule will always take precedence when they both apply (i.e., when one of my comments is an even row). I want any comment by me to always show up with the same color regardless of the odd/even rule.

So there you go — nice and simple, much better than the old days. Thanks, WordPress!

Filed under: CSS, PHP, Web, WordPress | Comments: 1 Comment »

Silliest Site Warning I’ve Seen In a While

I recently ran across the website LetStartUp.com.  It’s in the market of matching up people who own their own startups, people who are interested in partnering or investing in startups, etc.  It’s actually an idea I had a long time ago to fill an open niche I saw when trying to find similar services.  Back then this url was still available, but I guess someone else had the same idea!

I randomly ran across it again and decided to check it out, but was immediately met with this inane “error” message upon loading the home page:

Normally these types of messages are more geared toward viewers with low resolutions who may not be able to see the full width of a site.  Still terrible from a UI perspective to hammer your user with an alert, but at least (arguably) reasonable from a logical point of view if your layout will be visually truncated.  But warning me that my resolution (as opposed to my browser window) is too big?  That’s a new one to me. Sure enough, here is the code from their script:

1
2
3
4
5
if ((screen.width > 1024) && (screen.height > 768))
{
    alert('Your resolution is '+screen.width+'x'+screen.height+
        '. LetsStartUp.com is best viewed in 1024x768.');
}

WTF? So the recommendation is not that I resize my browser (which would be bad enough, although it is commonly done), but I’m expected to go into my computer’s settings and reduce the screen resolution for my entire operating system so that I can “best view” their (kinda crappy-looking, by the way) site? And that is crucial enough to stop me dead in my tracks on the home page of the site during my very first experience as a user of their site?

Note to the site author: I’m doing OK with my 2560×1600 resolution, and am able to view your site just fine, in all its glory. In fact, I am able to view more than one site at a time, one of the perks of having a resolution larger than 1024×768. You should try it sometime :)

Filed under: User Experience, Web | Comments: Comments Off

Firefox & Double-Hyphens in Comments

So in kicking off this blog, before I could even post something about stuff I’m working on, I ran into an interesting problem just setting up the blog itself that I’ll share.

I just freshly installed WordPress 2.9.1 and found a nice clean theme called Clean Home (version 1.2 at the time of install).  I’ll probably change it up later, but for now, it’s a nice simple clean slate to start off with.  After getting the basic site set up I decided to compare across my typical suite of testing browsers that I always use to verify web pages I’m working on (Safari, FF and Chrome on Mac, and FF, IE, Chrome and Opera on Windows).  I was primarily comparing the font rendering to see if I wanted to tweak anything, when I noticed that my non-blog pages (like the About page) had a weird rendering issue only in Firefox (both Mac and Win).  Basically, there was a post slug (title, date, author, category, etc.) that was not supposed to be there since they only show up within the blog section of the site.  Also, there was a --> displayed at the end of the slug, the telltale sign that an HTML comment tag did not get closed properly.  But this code is generated from a template on the server, so it’s exactly the same in all browsers (and works fine in everything BUT Firefox).  So what gives?

I examined the page source (found in page.php) and saw this right after the start of the <div class="post"> block:

<--uncomment for header tags-- <h1> ...[etc]

A big block of HTML — the page title and post slug section — are commented out (but still available to tinkerers like me, which I appreciate).  I have never run across the case where having a double-hyphen inside a comment would cause a problem, but being the genius hacker that I am, my first instinct was to remove that and refresh the page — voilà, no more post slug in FF.  The block of HTML is now properly commented out.

Out of curiosity I Googled this just to check my sanity, and sure enough, it’s a well-known “bug that’s not a bug” with versions of Firefox going back many years.  Basically, the HTML spec (up until version 5) allows whitespace between the -- and the > of a closing comment tag (although interestingly, not in an opening comment tag), and Firefox is apparently the only browser that actually enforces that rule.  I found a great write-up on this issue from a blogger who tried unsuccessfully to report this “bug” to Mozilla — if you are a web developer you’ll definitely appreciate it.

Anyway, problem solved and blog officially kicked off, all in one post!

Filed under: Browsers, Web, WordPress | Tags: , | Comments: Comments Off