Flutter Desktop Macos桌面端.dmg打包发布流程

1.环境配置

1.下载flutter macos版

macOS install | Flutter

2.配置环境变量

export PATH=${PATH}:"路径"/flutter/bin
export PUB_HOSTED_URL=https://pub.flutter-io.cn/

3.enable-macos-desktop

flutter channel stable; flutter upgrade

flutter config --enable-macos-desktop

4.检查环境

flutter doctor
 flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on Mac OS X 10.14.6 18G2022 darwin-x64,
    locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.
[!] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    ✗ Flutter requires Xcode 13 or higher.
      Download the latest version or update via the Mac App Store.
    ! CocoaPods 1.9.0 out of date (1.11.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.1)
[✓] VS Code (version 1.71.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

5. xcode与cocoapods安装

对于 macOS 桌面开发,除了 Flutter SDK 之外,您还需要以下内容:

  • Xcode
  • CocoaPods如果你使用插件

2.打包发布.dmg

1.打包macos应用

flutter build macos --release 

2.创建.dmg文件

安装 create-dmg shell脚本,执行如下指令:

#!/bin/sh
test -f Application-Installer.dmg && rm Application-Installer.dmg
create-dmg \
  --volname "Application Installer" \
  --volicon "application_icon.icns" \
  --background "installer_background.png" \
  --window-pos 200 120 \
  --window-size 800 400 \
  --icon-size 100 \
  --icon "Application.app" 200 190 \
  --hide-extension "Application.app" \
  --app-drop-link 600 185 \
  "Application-Installer.dmg" \
  "source_folder/"

#"Application-Installer.dmg"是.dmg文件名称。
#"source_folder/"是"flutter build macos --release"结果路径,如:/工程目录/build/macos/Build/Products/Release/xxx.app

3.产物.dmg

最终会在工程目录下生成 Application-Installer.dmg 文件,大功告成!注:打包发布都要cd到工程目录。

你可能感兴趣的:(flutter,flutter,macos,android)