codesign IPA and the code object is not signed at all problem

You know this journey starts with, “…I was so excited to get Mountain Lion and download the new Xcode.”  I’m now absolutely shocked as for the first time, I’m faced with a strange and unique predicament.  I cannot archive one of my commonly archived for Ad Hoc developer release iOS applications.  What happened?  Where did it start breaking?  I’ll share the facts here and maybe, just maybe, this might help out some poor soul out there.

Let’s start by saying this, how do you even know you’re having this issue?  The first sign of trouble is you build an archive file in Xcode for an “Ad Hoc” release.  The last step finishes up with a code signing or “codesign” process and a final saving of the IPA file.   Everything seems to work properly.   You then do one of the following, install via iTunes or upload the IPA to Test Flight.  All seems fine and grand.  The trouble has just begun.  Your users will begin reporting to you that they cannot download or worse they are seeing the “Failed to install” error.  You’re already in this hole now… what is going on?

My first gut reaction was to start building another archive and then another and each one had the same issue.  I finally realized that the Xcode Organizer tool was going to help me out.  I did the install using iTunes on my iPad 3 and monitored the iPad 3 console in Organizer.

Aug 28 21:07:55 unknown installd[7066] <Error>: unrecognized status -67068 from codesigning library
Aug 28 21:07:55 unknown installd[7066] <Error>: 00403000 verify_signer_identity: Could not copy validate signature: -402620415
Aug 28 21:07:55 unknown installd[7066] <Error>: 00403000 preflight_application_install: Could not verify executable at /var/tmp/install_staging.6ua8Zg/foo_extracted/Payload/MySpecialApp.app
Aug 28 21:07:55 unknown com.apple.itunesstored[7074] <Notice>: MobileInstallationInstall: failed with -1
Aug 28 21:07:55 unknown installd[7066] <Error>: 00403000 install_application: Could not preflight application install
Aug 28 21:07:56 unknown installd[7066] <Error>: 00403000 handle_install: API failed
Aug 28 21:07:56 unknown installd[7066] <Error>: 00403000 send_message: failed to send mach message of 71 bytes: 10000003
Aug 28 21:07:56 unknown installd[7066] <Error>: 00403000 send_error: Could not send error response to client

I can’t tell you how upsetting it was to see this error and to know that Xcode when archiving did not even make a peep about a code signing error.  I quickly opened up my friendly terminal and located my IPA file that I had just attempted to install.  I ran the famous command “codesign” and here is what it looks like.

Chris-Danielsons-MacBook-Pro-2:Desktop myUserAcct$ codesign -dvvv MySpecialApp.app
MySpecialApp.app: code object is not signed at all

So it’s clear to me that Apple has a fairly major issue on their hands that has seemingly let the user wander mindlessly into a trap thinking they were on a great journey of sorts.

So here is the question, how does one correct this issue?  Continuing to fail miserably… here is what I have done thus far to attempt to correct the issue.

  1. I have verified that all my certificates are in order.  Deleted my mobile provisioning profiles manually, re-added them from the Apple developer portal.
  2. Open Disk Utility and do a full verify and repair disk permissions.
  3. Do a full shutdown and startup of my computer.

None of these processes have fixed this issue.

I finally figured out the solution by trial and error.  In my case I had a folder name that matched the “Product Name” variable under build settings.   This also matched the entire project name!  So I simply changed one field.  I changed the “Build Settings” -> “Product Name” .  The value of MySpecialApp was changed to My-SpecialApp.  That was simply it!  I then logged back into the Apple developer portal and created a new App ID and mobile provisioning profiles for development and distribution and the rest is history.  My releases now work when deployed via the Ad Hoc distribution.

A final note on this.  This is definitely a bug that Apple should either alert the user that they have done something wrong and enable some sort of automated corrective action.  After archiving I still receive:

codesign -dvvv My-SpecialApp.ipa
My-SpecialApp.ipa: code object is not signed at all

So what gives? Something is very wrong here, but this solution works for now.

 

, , , , , , , ,

2 Comments

Linux Firmware Keyspan USB to Serial

Just wanted to share the difficult to find firmware that works between Linux and the awesome Keyspan USB to Serial devices.  I love these old Keyspan devices!  Anyways, here is the ‘dmesg’ signature for your perusal.

New USB device found, idVendor=06cd, idProduct=012a
New USB device strings: Mfr=1, Product=2, SerialNumber=0
Product: Keyspan USA-49WLC
Manufacturer: Keyspan, a division of InnoSys Inc.

On Debian 6, “squeeze”, and on Ubuntu images I simply copy the “keyspan.zip” file to the /lib/firmware/ folder, uncompress it and plug back in the device.  Everything works like a champ from that point on.

Firmware included for:

keyspan/mpr.fw
keyspan/usa18x.fw
keyspan/usa19.fw
keyspan/usa19qi.fw
keyspan/usa19qw.fw
keyspan/usa19w.fw
keyspan/usa28.fw
keyspan/usa28xa.fw
keyspan/usa28xb.fw
keyspan/usa28x.fw
keyspan/usa49w.fw
keyspan/usa49wlc.fw

Happy coding!

keyspan.zip

9 Comments

ePub Submission Got You Down?

Today I released my new interactive digital children’s book, Riley and the Magical Laundry Basket iPhone/iPad application.  I wanted to take the story to the next level by releasing an ePub version into Apple’s iBookstore.  The story is about Riley as she is transported away to an imaginary world via her magical laundry basket.  In this world she is trying to get to the cupcake palace. iTunes Linkhttp://itunes.apple.com/us/app/riley-magical-laundry-basket/id456764124?mt=8

The cover/title of Riley and the Magical Laundry Basket

Riley and the Magical Laundry Basket

I wanted to release Riley and the Magical Laundry Basket as an ePub book.  I was absolutely ecstatic as my final “.epub” file worked flawlessly and looked beautifully in my initial tests on iPad and iPhone.  Today, I decided I was going to move ahead and upload the file using iTunes Producer.  I became frantic as I discovered a host of errors produced by iTunes Producer and when I searched online, I didn’t find much help!  I’m going to take the esoteric “errors” you see and translate them for any/all people.  If you need help just add in a comment, but these were my basic errors and how I solved them today.

My first error encountered.  This error made me go cross eyed trying to figure out what exactly the trouble was.

“length of first filename in archive must be 8, but was 9”

Chris’ Translation & Solution:  make sure that the “mimetype” file is the first one compressed into your epub archive file.  Don’t worry I’ll show you how to fix it near the end of this post.

My second error:

“extra field length for first filename must be 0, but was 28” at Book (MZItmspBookPackage)

Chris’ Translation & Solution: the zip command or tool you are using is adding additional file attributes into the archive or compressed file.

Using the command line (terminal) on my Macbook I was able to fix both these issues.  I changed directory to the root of my epub book and ran the following command.

zip -X -r rmlb.epub mimetype *

The -X listed removes the extra file attributes (from issue #2) shown.  Explicitly defining that the mimetype file is the first file to compress fixes issue #1.  A little further explanation of the command shown…  The -r means “recursively”, basically add everything within the current directory including other sub-directories.  The rmlb.epub is the final name of the .epub file.  The * is a wildcard character telling the zip command to put everything into the archive.

My directory structure looked as follows.

Screenshot of ePub directory structure.

I saw many references to using the OEBPS folder, but in this case it is not necessary.  You just have to make sure that you add the “mimetype” file first into the archive.

After I did the following command, iTunes Producer accepted my ePub book and now I’m waiting for Apple’s approval.

Happy coding and I hope this helps you if you had an issue!

5 Comments

Timer Manager for Unity3D

It’s been a nearly a month since my last blog entry. Typically people disappear for long periods of time because they’ve either just begun a romantic charade or they just became insanely busy with work. Well in my case, I’m already happily married with a sweet little daughter so it’s clearly a work issue. If you haven’t guessed it yet from this site, I’m actually starting a new company named Monkey Prism. At Monkey Prism we’re in the midst of an up and coming Unity 3D iOS release. During our development cycle we were in need of a basic timer object. This example really serves as an object to learn from on how to use Time.time in your code to create a basic timer. Feel free to use this code in anyway that you like!

Here is how you call this MPTimer object.
Example 1

View Code CSHARP
//Example 1:
private MPTimer monkeyPrismTimer;
 
void Start() {
   /*
   Creates a timer object that will wait 5 seconds before calling 
   the ToggleExample method.  The false flag signifies that this object
   will not start the timer until the 
      monkeyPrismTimer.Active = true;
   has been set.
   */
   monkeyPrismTimer = new MPTimer(
      new MPTimerObject(gameObject, "ToggleExample", 5.0f), false);
}
 
public void ToggleExample() {
   Debug.Log("ToggleExample() called!");
}
 
void Update() {
   //daisy chain the timer running.  Every time it inactivates, we'll re-activate it.
   if (!monkeyPrismTimer.Active) {
      Debug.Log("Enabling the timer!");
      monkeyPrismTimer.Active = true;
   }
 
   //drive the timer
   monkeyPrismTimer.DoTimer();
}

Example 2 (auto-start the timer)

View Code CSHARP
private MPTimer monkeyPrismTimer;
 
void Start() {
   //create a 3 second timer that repeats 10 times.
   MPTimerObject mpTimerObject = new MPTimerObject(gameObject, "ToggleExample", 3.0f);
   mpTimerObject.repeatCount = 10;  // repeat it 10 times.
 
   //creates a timer object without auto-starting it.
   monkeyPrismTimer = new MPTimer(mpTimerObject, true);
}
 
public void ToggleExample() {
   Debug.Log("ToggleExample() called!");
}
 
void Update() {
   //drive the timer
   monkeyPrismTimer.DoTimer();
}

The file on my system is named: “MPTimer.cs“. Here it is! The meat and potatoes we’ve been talking about!

Download MPTimer.cs
using System;
using UnityEngine;
 
/// <summary>
/// A timer object that will be passed into the MPTimer class.
/// </summary>
public class MPTimerObject
{
	/// <summary>
	/// The target GameObject that contains the onCompleteMethod specified.
	/// </summary>
	public GameObject target;
	/// <summary>
	/// A string representing the method to call when the timer expires.
	/// </summary>
	public String onCompleteMethod;
	/// <summary>
	/// A float value in seconds representing how often you would like the timer to trigger.
	/// </summary>
	public float runForSeconds;
	/// <summary>
	/// An integer value representing the number of times you would like this timer to trigger before becoming inactive.
	/// </summary>
	public int repeatCount;
 
	public MPTimerObject() { }
 
	/// <summary>
	/// Creates a basic Monkey Prism timer object.
	/// </summary>
	/// <param name="targetCompleteMethodObject">
	/// A <see cref="GameObject"/> that is the targeted object that contains the "completeMethod" string parameter.
	/// </param>
	/// <param name="completeMethod">
	/// A <see cref="String"/> representing a method named contained within the GameObject specified.  Example:  "myMethod"
	/// </param>
	/// <param name="triggerTime">
	/// A <see cref="System.Single"/> float value in seconds.  5.0f would be 5 seconds.  This tells the timer to trigger in 5 seconds.
	/// </param>
	public MPTimerObject(GameObject targetCompleteMethodObject, String completeMethod, float triggerTime)
	{
		Init(targetCompleteMethodObject, completeMethod, triggerTime, 1);
	}
 
	private void Init(GameObject targetCompleteMethodObject, String completeMethod, float runForSeconds, int repeatCount)
	{
		this.target = targetCompleteMethodObject;
		onCompleteMethod = completeMethod;
		this.runForSeconds = runForSeconds;
		this.repeatCount = repeatCount;
	}
}
 
/// <summary>
/// A Monkey Prism timer object that allows for a user to trigger a method based on a time specified.
/// </summary>
public class MPTimer
{
	private MPTimerObject timerObject;
	private float startTime;
	private float endTime;
	private bool active;
	private int count;
 
	/// <summary>
	/// Create a new MPTimer object.
	/// </summary>
	/// <param name="mpTimerObject">
	/// A <see cref="MPTimerObject"/>
	/// </param>
	public MPTimer(MPTimerObject mpTimerObject)
	{
		Init(mpTimerObject, true);
	}
 
	/// <summary>
	/// Create a new MPTimer object.
	/// </summary>
	/// <param name="mpTimerObject">
	/// A <see cref="MPTimerObject"/>
	/// </param>
	/// <param name="activeState">
	/// A <see cref="System.Boolean"/> representing whether to start the timer immediately or to wait.  If true, the timer will kick-off immediately.
	/// </param>
	public MPTimer(MPTimerObject mpTimerObject, bool activeState)
	{
		Init(mpTimerObject, activeState);
	}
 
	private void Init(MPTimerObject mpTimerObject, bool activeState)
	{
		if (mpTimerObject == null || 
		    mpTimerObject.onCompleteMethod == null || mpTimerObject.target == null) {
			Debug.LogError("MPTimer Error: Invalid MPTimerObject specified.");
		}
		timerObject = mpTimerObject;
		Active = activeState;
	}
 
	/// <summary>
	/// The MPTimerObject get/set helper.  Setting a new timer object will inactivate the current timer.
	/// </summary>
	public MPTimerObject TimerObject
	{
		get { return timerObject; }
		set {
			active = false;
			timerObject = value;
		}
	}
 
	/// <summary>
	/// The Active get/set helper.  By setting this to "Active" you will instantly cause this method to be called.
	/// </summary>
	public bool Active
	{
		get { return active; }
		set { 
			if (value != active) 
				count = 0;
			active = value; 
			if (active) {
				startTime = Time.time;
				endTime = startTime + timerObject.runForSeconds;
				//Debug.Log("Start= " + startTime + ", End= " + endTime);
			}
		}
	}
 
	/// <summary>
	/// A method used for the "Update" call in your calling library.  If this method is not called, the timer is not automatically driven.
	/// </summary>
	public void DoTimer()
	{
		if (!active) return;
 
		if (Time.time >= endTime) {
			//Debug.Log("timer fired!");
			timerObject.target.SendMessage(timerObject.onCompleteMethod);
			if (++count >= timerObject.repeatCount)
				active = false; //toggle off.
		}
	}
}

, , , , ,

No Comments

Unity3D Projects, Version Control and Git

Remember when CVS was a pretty neat version control system for one guy working out of his garage? Then many of us became enamored with SVN, which was a nice upgrade offering many additional options than your standard CVS. There are many other version control software packages on the market as well, some cost money and others are free. When it comes to the Unity3D Pro game engine there really are two version control systems that come to mind.

  • Unity3D Asset Server  – Costs $500.00 (as of June 4, 2011).  It’s an add-on component that requires additional hardware resources to run on.  It doesn’t appear that you can run this thing in the cloud (i.e. Amazon ec2, or pick your favorite virtual flavor).
  • SVN – FREE, but a real pain to setup with your Unity3D project. What folders and data do you not upload into your repository? Unity has a how-to, but it still stinks when you have those .svn folders peppered throughout your project.

As of June 4, 2011 Unity3D Pro shares these two options on their website (including the HOW-TO).  http://unity3d.com/support/documentation/Manual/ExternalVersionControlSystemSupport.html

What if there was one more option that wasn’t discussed by Unity3D? What if this option was as easy as SVN, if not easier to implement?

Enter in Git. I have personally setup my Unity3D projects using SVN in the past and after using Git, I can’t stress how great this product is for your Unity3D projects. No more nasty .svn folders incidentally getting distributed in your software or irritatingly peppered throughout. Also, branches, tags and the ominous merges are handled inherently much better in Git. As a side note, Git was created for one of the most popular open source projects on the planet earth… Linux. And it was started by the king of handling merges… Linus Torvalds himself. Not that that should steer your thinking much, but I have to admit I was slow to begin using Git. Now that I’m using Git, I’ve already converted all my latest projects over to it because I just can’t seem to live without it’s simplicity and power.

So how do I integrate Git? I’m not going to go into detail on setting up your own Git repository here. You can easily set one up over at github.com. Or for the more adventurous, you can create your own Git repository and integrate a authentication/permissions or use straight SSH. BTW, I recommend to use gitolite for authentication/permissions. Gitolite, will make integration a snap without forcing you to create a handful of accounts on your Linux server. It also doesn’t hurt that Fedora and a few other big systems use and support Gitolite.

You still have to follow some of the Unity3D directions for creating an SVN friendly Unity3D project. More specifically, you need to follow the first 3 directions they list. Well here is my recipe…

Please note, this only applies to Unity Pro Licenses.

  1. Create a new project inside Unity and lets call it InitialUnityProject. You can add any initial assets here or add them later on.
  2. Enable Meta files in Edit->Project Settings->Editor
  3. Quit Unity (We do this to assure that all the files are saved).
  4. (My addition) Create a new Git repository for your project. Setup git on your local workstation and pull the empty repository down to a folder
  5. (My addition) Copy your new Unity3D project over to that local repository project folder.
  6. (My addition) Create a .gitignore using my recipe or a modification as shown below.
  7. (My addition) Startup Unity3D and open the project from the new local repository project folder.

Tools I use:
Git
GitX

See below for a .gitignore file which is stored at the root of your local repository location. It will take care of helping you avoid storing the wrong files into your Git repository!

# Unity3D .gitignore file.
#     Store this file at the root of your local repository.
.DS_Store
Library/AssetImportState
Library/AssetServerCacheV3
Library/FailedAssetImports.txt
Library/ScriptAssemblies
Library/ScriptMapper
Library/assetDatabase3
Library/cache
Library/expandedItems
Library/metadata
Library/previews
Library/guidmapper
Temp
*.pidb
build

Remember with Git, that you are operating on your local repository until you perform the git push origin master. This means you can bundle your commits into the parent version control!

Finally, I feel like I discovered a happy medium of finding a free alternative that works better than SVN with the Unity3D game environment.

Good luck with your projects and happy game developing!

, , , , ,

27 Comments