I have a flutter app which I built in Flutter for macOS. But I cannot figure out a way to codesign the Application.app package. I have searched the internet and couldn't get a proper way to do it.
3 Answers
The procedure is very simple. But it's not properly documented anywhere.
- Get a certificate from Xcode. The simplest step is to use Xcode, add a new certificate. Read more about it here https://help.apple.com/xcode/mac/current/#/dev154b28f09
- Once you have the certificate you need to find the identity for it to sign your app .
security find-identity -p codesigning
run this in terminal and copy hash it gives you against the certificate name you just created. - build the release version of your flutter app by running
flutter build macOS
in your project folder UPDATE flutter build macOS doesn't work any more. Tryflutter build macos
instead. Refer. Thank you @Bartosz for pointing it out in comments. cd
into the folder where your app is created. now runcodesign --deep --force --verbose --sign "<identity>" Application.app
Supply the hash we coped in step 2 in place of (Keep the quotes).
You should see something like this Application.app: signed bundle with Mach-O thin (x86_64) [com.application]
- Verify the signature
codesign --verify -vvvv Application.app
andspctl -a -vvvv Application.app
First one will give you something like
Application.app: valid on disk
Application.app: satisfies its Designated Requirement
Second one will give you something like
Application.app: accepted
source=Developer ID
origin=Developer ID Application: Spreaker Inc (xxx)
Read more about it https://pracucci.com/atom-electron-signing-mac-app.html
Flutter Desktop is wonderful. But coming from an Android Dev background, I had no idea how to sign in mac. Hope it helps someone.

- 940
- 9
- 22
-
I'm not familiar with the details of Electron's build process, so maybe doing everything manually is necessary there, but it's definitely not needed for Flutter. – smorgan Feb 02 '20 at 18:57
-
@smorgan Why's that? `flutter build` gives you an unsigned `.app` file that the system refuses to run because it's from an unidentified developer. You have to sign it with your Apple identity and there doesn't seem to be any automatic way for that in Flutter tools. – Michael Antipin Nov 16 '20 at 17:46
-
`flutter build` builds the Xcode project. If you configure it to do signing, it will build a signed app. As my answer to the question said. – smorgan Nov 16 '20 at 22:15
-
I believe `flutter build macOS` no longer works. Now it's `flutter build macos` – kosiara - Bartosz Kosarzycki Feb 13 '21 at 12:50
-
I have build the app but where to find the package file?@Jude Osbert K – Dolphin Nov 16 '21 at 05:08
You can simply set your signing identity in the Xcode project, using the UI or an xcconfig, as with any standard macOS application. There's nothing Flutter-specific about the signing process.

- 20,228
- 3
- 47
- 55
For me, it's much simpler when using Copy App
in Distribute App
.
- Open macOS project in XCode, select
Product
>Archive
. - When it's completed, select
Distribute App
>Copy App
and then choose destination for saving the executable file.
Then you can share that file with others.

- 1,032
- 14
- 38