Apr 11 2011

Xcode4 bad codegen, pointer diff

We recently upgraded to Xcode 4 and we found a lot of our static libraries no longer built due to a change Apple made with symbol visibility settings.

The errors crop up something like this:

ld: bad codegen, pointer diff in b2ContactListener::b2ContactListener()to global weak symbol vtable for b2ContactListener

The fix we found was to modify the build settings for every static library, as well as the App to:

Symbols Hidden By Default = YES
Inline Methods Hidden = NO

Hopefully this helps someone else out with the same problem!


Aug 27 2010

Disable deprecated warnings with GCC

Recently I wrote some conditional code to call various methods depending on the version of iOS running on the device. A problem I came across was that because I still called some deprecated methods I was getting warnings during my build. As I treat all warnings as errors I had to find a solution which would compile. #pragma was the answer.

You can use the following line to disable warnings for depreciated calls:

#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

And use this to re-enable it:

#pragma GCC diagnostic warning "-Wdeprecated-declarations"

Here’s how I used it:

#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- (id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier
{
  if([super respondsToSelector:@selector(initWithStyle:reuseIdentifier:)])
  {
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
      [self setupCell];
    }
  }
  else
  {
    if(self = [super initWithFrame:CGRectZero reuseIdentifier:reuseIdentifier])
    {
      [self setupCell];
    }
  }
  return self;
}
#pragma GCC diagnostic warning "-Wdeprecated-declarations"

Jan 12 2010

The application does not have a valid signature

Had a frustrating issue this weekend with one of my Xcode projects. I’ve been working with this project for months, without problems, and then suddenly the application won’t install onto the Simulator, and when ran onto the device, I’m greeted with the error: “The application does not have a valid signature.”

Note this is not the same as the more common invalid provisioning profile error. I of course, googled my problem with the error message, but to my surprise found very little of anyone else with the same problem.

After a slow process of elimination, I finally tracked down the problem.

In my application, the directory structure of the resource files is very important. Added folders with the default option in Xcode, adds them as a group, and in the resulting application, all the files are copied into the top directory. This creates problems with you have files which share the same name, in different directories.

The solution to this is of course use reference folders (the second option you can select when added files to the project).

This is all fine and dandy, but what caused my Xcode project to go haywire, was the fact that my reference folder was called “resources”. The solution, was simply to rename the folder to “resource” (or anything else in fact), and after a clean, it works.

Very very strange error, but thankfully with an easy fix, once you know how!