macosxamarinmonomacinfo.plistxamarin.mac

Rename causes "You can't open the application "XXXXX" because it may be damaged or incomplete." after updating to Xamarin.Mac


Edit: Turns out this was not a codesigning issue, so I'm updating to help anyone who runs into the same problem.

After updating a MonoMac app to Xamarin.Mac, if I changed the name of the app, I would get the message "You can't open the application "XXXXX" because it may be damaged or incomplete." It looks like it could be a codesigning issue because when I would run codesign --verify I would get code object is not signed at all.

Original question:

I recently updated a MonoMac app to Xamarin.Mac. In the process, something in the codesigning step seems to have changed. Specifically, now when I rename the app bundle, I get codesigning signature errors, both from the GUI and from the command line tools. It seems that if the app bundle does not match CFBundleName, the signature isn't valid.

For example, if I run codesign --verify --deep -vvvv Program.app (where Program matches the CFBundleName, I get

Program.app: valid on disk
Program.app: satisfies its Designated Requirement

However if I change the name to Program2.app and run codesign --verify --deep -vvvv Program2.app, I get:

Program2.app: code object is not signed at all

Move it back, and I get a successful signature again.

From looking at the MonoMac app vs. the Xamarin.Mac app, there are a few differences:

  1. archived-expanded-entitlements.xcent is now placed in Contents/Resources
  2. Info.plist gets compiled to some binary-ish version.
  3. Contents/MonoBundle now includes libMonoPosixHelper.dylib, which apparently needs signing.
  4. PkgInfo is now included in Contents, with contents APPL????

Why do the codesigning tools care about the name of the app all of a sudden? How can I make it not care about the name?


Solution

  • It turns out that the problem was a change in the update from MonoMac to Xamarin.Mac that somehow set it to look for the executable to be named the same as the app bundle, so if you changed Program.app to Program2.app, OS X would look to run Contents/MacOS/Program2 instead of Contents/MacOS/Program. I'm still not sure why the MonoMac version worked when renamed, but clearly it had some other pointer to the correct executable file.

    The solution for Xamarin.Mac is to add

    <key>CFBundleExecutable</key>
    <string>[Original app name]</string>
    

    to Info.plist. This tells OS X where to look for the executable, and allows you to rename the app without issue.