Resolving iPhone code signing error

Posted by Sitt Sen Chok | Filed under , ,

During the deployment of an iPhone application to the device from xcode, issue may be encountered during the code signing stage which prevents the completion of the deployment task. The specific error message I encountered was “object file format invalid or unsuitable”. The issue may be due to installation of the iPhone SDK on an unsupported environment which in this case is PowerPC machine. I cannot be totally sure that this is the real cause of the problem.

The issue was resolved based on the solution provided in Apple Support forum. The following are the steps which will require administrator (may use sudo) privillage:

  1. Make a copy of the existing codesign executable.

    mv /usr/bin/codesign /usr/bin/codesign.orig

  2. Create a new codesign file with the following content

    #!/usr/bin/perl
    #
    $appDir=$ARGV[$#ARGV];
    @tmpAry=split(/\//,$appDir);
    $baseAppName=$tmpAry[$#tmpAry];
    $baseAppName=~s/\.app$//;
    $realAppName="$appDir"."/$baseAppName";
    $sign=0;

    for($b=0;$b<$#ARGV;$b++) { 
         if ($ARGV[$b] eq "-s") { 
              $sign=1;
         }
    }

    $mums=`file $realAppName`;

    if($sign==1 && $mums=~/executable arm/) {
         #print "Signing armv6..\n";
         $dev="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/";
         $tmp="$appDir"."/tmpbin";
         `$dev/lipo -create $realAppName -output $tmp`;
         `mv $tmp $realAppName`;
         system("/usr/bin/codesign.orig",@ARGV);
         `$dev/lipo -thin armv6 $realAppName -output $tmp`;
         `mv $tmp $realAppName`;
         system("rm $appDir"."/CodeResources");
         system("cp $appDir"."/_CodeSignature/CodeResources $appDir"."/CodeResources");
         exit 0;
    } else {
         exec '/usr/bin/codesign.orig',@ARGV;
    }

  3. Make the new codesign file executable.

    chmod 755 codesign

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading