Search code examples
macosflutterdarthybridflutter-desktop

How to release a macos app written with flutter


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.


Solution

  • The procedure is very simple. But it's not properly documented anywhere.

    1. 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
    2. 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.
    3. 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. Try flutter build macos instead. Refer. Thank you @Bartosz for pointing it out in comments.
    4. cd into the folder where your app is created. now run codesign --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]

    1. Verify the signature codesign --verify -vvvv Application.app and spctl -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.