I’ve developed a macOS app, but I’ve had trouble using a script to fully codesign it and package it into a .dmg file. I was only able to complete codesigning using the third-party app itself—not via command-line scripts.
Is it possible to write a script that automates the entire process of codesigning the app?
To provide the best user experience for those downloading the app outside of the Mac App Store, is it correct to first package it as a .app and then wrap that into a .dmg file for distribution?
Currently, the app is available on the web as a .dmg. When downloaded, it appears in a folder and can be double-clicked to launch. However, macOS displays a warning that it was downloaded from the internet. Can I use a script to remove that quarantine warning?
If possible, I’d appreciate a step-by-step explanation and a sample command-line script to:
Codesign the app properly
Package it into a signed .dmg
Remove the quarantine attribute for local testing or distribution
Is the reason I was only able to codesign it inside the third-party app due to how that app was built, or can this always be done from the command line?
If Gatekeeper presents an alert and lets the user easily proceed, that’s the expected behaviour for apps that are directly distributed. Apple Support has an article, Safely open apps on your Mac, that explains this process.
I generally recommend that you sign everything from the inside out and then notarise your outermost container. So, sign your app, sign your disk image, notarise your disk image, and then staple your disk image.
Note It’s better to reply in a reply rather than in the comments. If you reply in the comments, I can’t quote you nicely )-:
Otherwise, it misses the
MicrosoftCSharp.dll
.
That sounds like something you should raise with your tool vendor.
For context, .dll
files are not considered code by Apple’s code signing infrastructure. Given that, you should expect them to be packaged inside your app’s bundle as data, that is, somewhere within Content/Resources
. See the discussion of scripts in Placing Content in a Bundle.
Finally, some general links.
We have detailed instructions for signing a Mac product outside of Xcode in:
And there are links to many other docs and resources in the Trusted Execution Resources post.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"