• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

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

武飞扬头像
天若子
帮助1

1.环境配置

1.下载flutter macos版

macOS install | Flutter

2.配置环境变量

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

3.enable-macos-desktop

  1.  
    flutter channel stable; flutter upgrade
  2.  
     
  3.  
    flutter config --enable-macos-desktop

4.检查环境

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

5. xcode与cocoapods安装

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

2.打包发布.dmg

1.打包macos应用

flutter build macos --release 

2.创建.dmg文件

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

  1.  
    #!/bin/sh
  2.  
    test -f Application-Installer.dmg && rm Application-Installer.dmg
  3.  
    create-dmg \
  4.  
    --volname "Application Installer" \
  5.  
    --volicon "application_icon.icns" \
  6.  
    --background "installer_background.png" \
  7.  
    --window-pos 200 120 \
  8.  
    --window-size 800 400 \
  9.  
    --icon-size 100 \
  10.  
    --icon "Application.app" 200 190 \
  11.  
    --hide-extension "Application.app" \
  12.  
    --app-drop-link 600 185 \
  13.  
    "Application-Installer.dmg" \
  14.  
    "source_folder/"
  15.  
     
  16.  
    #"Application-Installer.dmg"是.dmg文件名称。
  17.  
    #"source_folder/"是"flutter build macos --release"结果路径,如:/工程目录/build/macos/Build/Products/Release/xxx.app
学新通

3.产物.dmg

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

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfkjkke
系列文章
更多 icon
同类精品
更多 icon
继续加载