macOS app built with Unity hangs upon launch after signing with codesign

I am trying to submit a macOS app built with Unity to Mac App Store. I followed the instructions mentioned in the Unity documentation, Delivering your application to the Mac App Store.

I am able to run the Build command for macOS and get a .app bundle for my app. I am also able to launch it and it runs fine. However, after running the following codesign command as mentioned in the linked document above, the app freezes upon launch and has to be force quitted. This is the codesign command line that I am running:

codesign -o runtime -f --deep -s '3rd Party Mac Developer Application: DEVELOPER NAME' --entitlements "GAMENAME.entitlements" "/AppPath/GAMENAME.app"

I have a paid developer license with Apple, have set up the certificates in keychain as mentioned in the document. I also managed to check that the app bundle was indeed signed by running the command line:

codesign -dv --verbose=4 GAMENAME.app

Running the above command displays that it’s signed with my 3rd Party Mac App Developer certificate.

I have tired looking for a way to export the Xcode project out from Unity app, so I can attempt to build and sign it with Xcode, but after searching the Web, I realized that Unity doesn’t have support for exporting the Xcode project for macOS app yet (it could do for iOS).

I am running the current latest version of all the software, and the same are mentioned below:

  1. macOS Catalina 10.15.1

  2. Xcode 11.2.1

  3. Unity 2019.2.13

What is it that may be going wrong? What other avenues do I have? I am looking for distributing the app only via the Mac App Store for the time being. This is going to be a paid app (if that’s relevant).

I was able to get a solution for the same here:

https://stackoverflow.com/a/59183019/6995250

It is quoted below:

```If you are building the .app from the command line (using Unity’s command line invocation), try building from the editor instead.

Confirm you are not building a 32 bit-only binary.

Try removing -o runtime from your codesign command, this is the only part of your process that differs from mine, and mine works fine.

Otherwise, when uploading to the App Store, I believe Xcode will sign for you. While this will not be different from codesign, Xcode may check if you accidentally blocked or otherwise misconfigured running binaries signed by you on your particular machine. You should test on a different machine or macOS VM.```

1 Like

Those are several different possible solutions. Which one worked for you?

Removing -o runtime from the command line did the trick

1 Like

Hi, I have a similar problem. But removing -o runtime doesn’t help … I suspect that my problem may be in chmod -R a + __ xr__ “/path/to/GAMENAME.app” this comand send me error “Invalid file mode: a + __ xr__”.
I changed it to “a+xr”… What are your chmod command options?

@Goodfeel Apparently there’s an issue with how the command line gets rendered in Web browser.

chmod -R a + __ xr__

is not a valid command line. The underscores are incorrectly displayed.

The correct command line to use is as follows:

chmod -R a+xr "/path/to/GAMENAME.app"

I’ve been having this issues for ages with no luck. 3 separate apps, all the same issue. I even tried the new Xcode build project support in the recent unity and still an issue.

Will try removing -o runtime now!

Seemed not to work. Fails at another point now, not sure if it go further or not as far!