views:

1238

answers:

4

Hey guys,

I have a weird issue. Codesign refuses to sign this big project I have, project A, but does signs the other, project B. However, when I have signed project B, it also can sign project A all of a sudden. I am 100% certain I didn't change anything else. The steps I took were:

Try to build, sign A - fails on signing
Try to build, sign B - succeeds
Try to build, sign A - succeeds

Transcript:

CodeSign build/Debug-iphoneos/CPPlayer.app
cd /Users/nick/CPPlayer
setenv CODESIGN_ALLOCATE /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/usr/bin/codesign -f -s "iPhone Developer: Nick Overdijk (PM7C8QKTYS)" --resource-rules=/Users/nick/CPPlayer/build/Debug-iphoneos/CPPlayer.app/ResourceRules.plist --entitlements /Users/nick/CPPlayer/build/CPPlayer.build/Debug-iphoneos/CPPlayer.build/CPPlayer.xcent /Users/nick/CPPlayer/build/Debug-iphoneos/CPPlayer.app

/Users/nick/CPPlayer/build/Debug-iphoneos/CPPlayer.app: object file format invalid or unsuitable
Command /usr/bin/codesign failed with exit code 1

In pictures: See here (imageshack gallery)

Is there anything I could've missed? Any ideas how this can happen? I got everything working now and this seems a cure for my problem, but I'd like to understand what is happening.

Sometimes it also works like this:
Build/sign A - succeeds
Build/sign A - fails
Build/sign B - succeeds (B always seems to succeed)
Build/sign A - succeeds
Build/sign A - fails

So, after every successful build of A, I have to build and sign B to be able to sign project A again. I can rebuild project B any number of times in succession, it always succeeds.

I'm not sure if it matters, but also when I try to run it in the simulator (debug mode for iPhone OS 3.1.2) it fails to install each other time. So:

Build/run - Fails
Build/run - Works
Build/run - Fails
Build/run - Works

This goes only for Project A, I can build and run project B as many times as I like, I never get the message that the installation failed.

Thanks in advance,
Nick

+1  A: 

Searching for the specific error message

object file format invalid or unsuitable

I got these links:

http://iphone.galloway.me.uk/2009/04/json-framework-codesign-object-file-format-invalid-or-unsuitable/

which suggest that your ResourceRules.plist is not set up correctly. That solution seems to have helped a lot of folks with this problem.

cdespinosa
Sorry, that doesn't do the trick. Still the same problem. Works once, then I have to rebuild/sign the other project (B) again. Project B is a iPhone app that displays a tableview with 1 clickable cell, which, when clicked, changes the view to another one. A tutorial program really. Nothing fancy in there.
Nick
I don't know if it's interesting, but my I can also simulate the project only trying to build and run it twice. It fails each other time. More clearly explained in original post.
Nick
Thank you I this fixed my problem.
OscarMk
+3  A: 

The problem could be too many info.plist files.

I had the same problem (alternating codesign success and failure).

I had added a directory of source code to my project, with "add existing files" on the directory. Turns out there was a info.plist file in the directory, so I now had 2 of them in my project. I deleted the new one and removed it from the project, and my problem was solved.

Michael
You are my hero! Thanks a lot, this was indeed the case. I was planning on making targets, so included a Info.plist in the "target's directory" but then I didn't create targets so I indeed had an Info.plist and some other Info.plist (with some other name but I set xcode to use that file as Info.plist). Thanks a bunch. :)
Nick
A: 

Make sure you don't have more than one Info.plist file in your target!

Robert