When you would export your app for macOS from Unity, you might see, that when people on another Macs would try to open that — they would see an alert popup, that will tell them that this is an app from unidentified developer, with ability only to close that popup. Experienced Mac users would know, that to open such an app they would need to right click on .app file, then hold cmd button, and click open. Mac would still prompt them with popup, but now with 2 buttons, 1 of them would allow user to application.
Of course, when you publish your app live, you don’t want your users to meet such things on very first step of their experience with app. To fix that, you need to sign your application with Developer ID certificate.
For this you would need to have Apple Developer(team or individual) account. I guess you do, so lets get further.
First thing first, you need to create certSigningRequest. Open KeyChain application — click on launchpad, write down KeyChain, and click on app’s icon.
Click on KeyChain Access in topbar, select Certificate Assistant -> Request a certificate from a certificate authority.
In next popup window select Saved to disk, click continue and save generated file at Desktop.
Now lets go to http://developer.apple.com and login with your credentials.
Choose Certificates, Identifiers & Profiles.
In next screen, ensure you have switched to macOS plaftorm. In Certificates section, click on Production.
Then, click on + button.
On next window in Production — select Developer ID and continue.
Further, select Developer ID Application and continue. Continue once again. Click on choose file, and navigate to certSigningRequest we created at very first step, and saved on desktop.
Click continue and download the certificate. Click on downloaded file, KeyChain app would be opened. In KeyChain app, navigate to Certificates, and find over there an entry with following name: Developer ID Application: (Your account name, here) (ID). Select it and store somewhere in text file this line : Developer ID Application: (Your account name, here) (ID).
Ok, we are almost there! Now lets make some scripting. Create an empty TextFile, and write down following script, where /Users/pavelbaslak/Downloads/MyApp.app is the path to your application, and Developer ID Application: (Your account name, here) (ID) is the string from KeyChain you have stored above. For sure, you can put your application to Downloads folder, and just change pavelbaslak — to your logged in user name, and MyApp — you your application name.
Full script below:
echo —sign frameworks —
codesign —force —verify —verbose —sign «Developer ID Application: (Your account name, here) (ID)» /Users/pavelbaslak/Downloads/MyApp.app/Contents/Frameworks/Mono/MonoEmbedRuntime/osx/libmono.0.dylib
codesign —force —verify —verbose —sign «Developer ID Application: (Your account name, here) (ID)» /Users/pavelbaslak/Downloads/MyApp.app/Contents/Frameworks/Mono/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib
echo —sign app—
codesign —force —verify —verbose —sign «Developer ID Application: (Your account name, here) (ID)» /Users/pavelbaslak/Downloads/MyApp.app
codesign -vvv -d /Users/pavelbaslak/Downloads/MyApp.app
Now we should be good! Open Terminal(Launchpad — write down Terminal), and just copy paste our script over there, and click Enter.