You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级macOS 13后Flutter macOS应用DMG分发异常求助

macOS 13下Flutter应用DMG无法打开的解决方法

问题概述

在macOS 12环境下,无需额外证书或配置即可生成可正常分发的Flutter应用DMG文件,但升级至macOS 13.6.4后,相同流程生成的DMG中,用户双击应用会提示“应用‘app_name’无法打开”,代码和配置未做任何修改。

环境详情

  • Flutter版本:3.22.2
  • macOS版本:13.6.4
  • 分发方式:DMG

现有操作流程

  1. 构建Release版本应用:flutter build macos --release
  2. 使用以下appdmg配置文件生成DMG:
{
  "title": "App name",
  "icon": "app_icon.icns",
  "contents": [
    { "x": 448, "y": 344, "type": "link", "path": "/Applications" },
    { "x": 192, "y": 344, "type": "file", "path": "../../build/macos/Build/Products/Release/appname.app" }
  ]
}
  1. 执行DMG生成命令:appdmg installer/dmg_creator/config.json installer/dmg_creator/appname.dmg

已尝试的排查动作

  • 确认应用构建过程无报错
  • 检查并确保应用拥有必要的系统访问权限
  • 多次重新生成DMG文件

解决方案建议

1. 完成代码签名与公证(macOS 13强制要求)

macOS 13对未签名应用的Gatekeeper限制大幅收紧,分发的应用必须经过开发者签名和Apple公证:

  • 签名应用:使用你的Apple开发者证书对应用进行签名
    codesign --deep --force --sign "Developer ID Application: 你的姓名 (Team ID)" build/macos/Build/Products/Release/appname.app
    
    替换命令中的证书名称和Team ID为你自己的开发者信息。
  • 提交公证:先将应用打包为zip,再提交至Apple公证服务
    # 打包成zip
    ditto -c -k --sequesterRsrc --keepParent build/macos/Build/Products/Release/appname.app appname.zip
    # 提交公证(需提前配置notarytool密钥链)
    xcrun notarytool submit appname.zip --keychain-profile "你的公证配置文件" --wait
    
  • 绑定公证凭证:公证通过后,将凭证绑定到应用上
    xcrun stapler staple build/macos/Build/Products/Release/appname.app
    

2. 修复应用文件权限

生成DMG前,确保应用文件权限符合macOS要求:

chmod -R 755 build/macos/Build/Products/Release/appname.app

3. 验证签名有效性

在生成DMG前,先检查应用签名是否有效:

codesign -vvv build/macos/Build/Products/Release/appname.app

若输出包含satisfies its Designated Requirement,说明签名有效;若有错误,根据提示修正签名问题。

4. 临时解决用户打开问题

如果用户紧急需要打开应用,可让其右键点击DMG内的应用图标,选择「打开」,可临时绕过Gatekeeper限制(仅作临时方案,正式分发必须完成签名公证)。

内容的提问来源于stack exchange,提问作者Nidhi Gokani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 00:05:14