Blog Index

Entries in xcode (3)

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.

 

Monday
Feb282011

Binary file names cannot contain a space

If you try to submit an app with a blank space in the app name, you may run into this error at the validation phase: "Binary file names cannot contain a space"

To fix this, follow the steps below:

Step 1) Right click on the app that you just "Build and Archive" on. Select Show in Finder.


Step 2) Proceed to remove the blank name out of the .app file and .dSYM file. Double click ArchiveInfo.plist to edit it in Property List Editor.


Step 3) Update the entries in ArchiveInfo.plist by removing the blank space from the XCApplicationName and XCApplicationFilename and save the file.

Resubmit the app and it should go through without a hitch. Hopefully this will be fixed in future version of Xcode.

Monday
Feb152010

Renaming Project in Xcode the Simple Way

 

Ten simple steps to renaming your Xcode project in Xcode 3.2.1 without mucking with your xcodeproj file.

1) Projects->Rename

 

2) With the project renamed, now rename your AppDelegate using Refactor.  Go into your AppDelegate class, place your cursor in the class name, and right click to select Refactor.  Enter the new class name in the Refactor dialog box.

3) Now we are left with a few things to rename: your app name, info.plist file and your precompiled header (.pch).  For your pch file, you can simply rename it directly in Xcode.

4) Next, go to Targets.  Go ahead and change your target name to your new app name.

5) After that, right click on your select Get info.

 

 

6) Update your precompile header file in build settings.

 7) Update your info.plist in build settings.

 

8) Go to Build -> Clean All Targets.

9) Build your project.

10) (Optional) Don't forget to change your bundle identifier in your info.plist as appropriate.