Blog Index
« Don't judge an error by its message | Main | UIView Animation - Beam me up Lambda »
Sunday
Apr172011

Xcode Build and Archive Sharing Problem (and Solution)

In this post I assume that you know how to create an ipa file from Xcode.  For info on how to do that, check this article out: http://support.testflightapp.com/kb/tutorials/how-to-create-an-ipa-xcode-3

Recently I ran into an annoying issue while trying to create an ipa file using Build and Archive.  Xcode would compile and verify the app fine, but when I tried to share the archive application (via Organizer->Archived Applications->Share), a spnner would appear and go away and the usual Save ipa file dialog would not appear.

It's apparent (or maybe not) that something is causing Xcode to bail out of the process.  The next step is to figure out how we can get more info that tells us why Xcode is not behaving the way it normally does.

To achieve that, let's eliminate Xcode out of the picture and get our hands dirty by building the app from the good old terminal and hopefully that will allow us a better picture on what went wrong.

1. Build the project to .app file 

xcodebuild -target "${PROJECT_NAME}" -sdk "${TARGET_SDK}" -configuration Release

In our case, the command is

xcodebuild -target "Word Tracer" -sdk "iOS 4.2" -configuration "Ad Hoc"

Note: You can skip this step by building in Xcode. 

2.  package .app file into an .ipa file

/usr/bin/xcrun -sdk iphoneos PackageApplication -v"${RELEASE_BUILDDIR}/${APPLICATION_NAME}.app" -o"${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPER_NAME}" --embed "${PROVISONING_PROFILE}”

In our case, the command is 

/usr/bin/xcrun -sdk iphoneos PackageApplication -v build/Ad\ Hoc-iphoneos/WordTracer.app -o WordTracer.ipa --sign "test name" --embed "/Projects/WordTracer/test.mobileprovision"

Sure enough, I got the error below after running the command.

+ /usr/bin/codesign --verify -vvvv -R=anchor apple generic and (certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)) /tmp/r3kFZTMcqd/Payload/WordTracer.app

Program /usr/bin/codesign returned 1 : [/tmp/r3kFZTMcqd/Payload/WordTracer.app: a sealed resource is missing or invalid

/tmp/r3kFZTMcqd/Payload/WordTracer.app/letter_data/hei_计.plist: resource added

/tmp/r3kFZTMcqd/Payload/WordTracer.app/letter_data/hei_计.plist: resource missing

]

Great, now we got more info that we did in Organizer.  Armed with this piece of info we can begin to investigate what halted the build process. It looks like hei_计.plist is the culprit. I double checked the file name in terminal. It turned out that there is a character \036 in it which won't appear in Finder (another reason why you should always rely on Terminal for things like this).  A quick conversion from \036 (octal) to hex gives us 0x1E.  It looks like this is a control character of some sort (http://www.fileformat.info/info/unicode/char/1e/index.htm) and this is what was causing a hiccup in the ipa packaging process.

I proceeded to remove the character \036 from the filename, rebuilt the app and this time Organizer allowed me to save the ipa file like it normally does.

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (3)

Hello Sir,
I went through your post and followed each step to create an ipa file using terminal; I was successful in creating an ipa file(I assume this as no error was returned) but I was not able to find out where the ipa file was stored finally.
Please tell me what is the default destination directory?

September 12, 2011 | Unregistered CommenterGaurav Keshre

I forgot to mention that that as in terminal I was able to create ipa but the problem with xcode persists ans still it silently ignores when I try to "Save to Disk" the created ipa file.
Any kind of guidance on this will be very much helpful for me.

September 12, 2011 | Unregistered CommenterGaurav Keshre

@Gaurav From our experience reinstalling Xcode seems to help fixed the problem.

October 12, 2011 | Registered CommenterBoon Chew

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>