为什么 MacOS 桌面版 Flutter 上的 HTTP 请求在 Release 上不起作用?
Why is HTTP Request on Flutter for MacOS desktop not working on Release?
我正在进行 HTTP 调试或配置文件构建,并且工作正常。但是如果我切换到 Release 它就不再有效了
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: Failed host lookup: '*******.*******.*****.io' (OS Error: nodename nor servname provided, or not known, errno = 8)
#0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:681)
#1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1808)
#2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27)
#3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237)
#4 SecureSocket.startConnect (dart:io/secure_socket.dart:60)
#5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437)
#6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2808)
#7 _HttpClient._getConnection (dart:_http/http_impl.dart:2813)
我假设是网络权限问题,但我找不到我需要添加权限的地方(info.plist?)以及我需要添加什么权限?
[✓] Connected device (3 available)
• iPad Pro (12.9-inch) (5th generation) (mobile) • 00008103-000E44D10C3B001E • ios • iOS 15.1 19B74
• macOS (desktop) • macos • darwin-arm64 • macOS 12.0.1 21A559 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
检查 this MacOS flutter 文档。
在 macos/Runner/DebugProfile.entitlements
和 macos/Runner/Release.entitlements
中添加以下行:
<key>com.apple.security.network.client</key>
<true/>
我正在进行 HTTP 调试或配置文件构建,并且工作正常。但是如果我切换到 Release 它就不再有效了
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: Failed host lookup: '*******.*******.*****.io' (OS Error: nodename nor servname provided, or not known, errno = 8)
#0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:681)
#1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1808)
#2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27)
#3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237)
#4 SecureSocket.startConnect (dart:io/secure_socket.dart:60)
#5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437)
#6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2808)
#7 _HttpClient._getConnection (dart:_http/http_impl.dart:2813)
我假设是网络权限问题,但我找不到我需要添加权限的地方(info.plist?)以及我需要添加什么权限?
[✓] Connected device (3 available)
• iPad Pro (12.9-inch) (5th generation) (mobile) • 00008103-000E44D10C3B001E • ios • iOS 15.1 19B74
• macOS (desktop) • macos • darwin-arm64 • macOS 12.0.1 21A559 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
检查 this MacOS flutter 文档。
在 macos/Runner/DebugProfile.entitlements
和 macos/Runner/Release.entitlements
中添加以下行:
<key>com.apple.security.network.client</key>
<true/>