【问题标题】:How to enable Flutter internet permission for macos desktop app?如何为 macos 桌面应用启用 Flutter 上网权限?
【发布时间】:2020-07-26 12:59:54
【问题描述】:

我正在尝试开发也可以在 destkop 上运行的 Flutter 应用程序。 此应用正在使用 http 包:

import 'package:http/http.dart'

当我尝试执行 http 请求时,我得到了这个异常:

 SocketException: Connection failed (OS Error: Operation not permitted, errno = 1), address = firebasedynamiclinks.googleapis.com, port = 443

此应用在安卓和iOS上运行,如何为macos启用此权限?

我正在使用 IntelliJ IDE,所以这个答案让我不满意Flutter - http.get fails on macos build target: Connection failed

【问题讨论】:

标签: flutter dart flutter-desktop flutter-http


【解决方案1】:

你需要添加:

<key>com.apple.security.network.client</key>
<true/>

macos/Runner/DebugProfile.entitlementsmacos/Runner/Release.entitlements

这已记录在here

【讨论】:

  • 非常重要:不要在 节点上添加任何空格,...格式化此文件时,您的 IDE 可能会保存。这将导致稍后出现模糊的代码签名问题。
【解决方案2】:

您应该通过 Xcode 为您的项目授予“传出连接(客户端)”权限。完整的解释检查this link

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2022-11-21
  • 2019-03-14
  • 2020-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-17
  • 2022-06-15
相关资源
最近更新 更多