macOS app built with Unity hangs upon launch after signing with codesign command in Terminal

I am trying to submit a macOS app built with Unity to the 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 (Individual) developer license with Apple, and have properly set up the certificates in keychain as mentioned in the document. I also managed to check that the app bundle was 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 tried 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 can do the same 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


My questions are:


1. What is it that may be going wrong?


2. What other avenues do I have?


I am looking for distributing the app exclusively via the Mac App Store for the time being. This is going to be a paid app (if that's relevant).

Accepted Reply

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.

Replies

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.

My app is not targeting yet the app store so i'm building using my Developer ID Application certificate

I'm building now by xcode 13.2 a Unity 2021.1.28f1 produced xcodeproj on macOS 11.6.2

The produced app bundle is notarized during Archiving it and

  • running seamlessly on macOS 11.6.2 even if no entitlements exception is used
  • freezing on macOS 10.15.7 till the "Allow Unsigned Executable Memory" (com.apple.security.cs.allow-unsigned-executable-memory) entitlements is not added during the build

So now the solution was for me to add com.apple.security.cs.allow-unsigned-executable-memory to the app entitlements