flutter 网络请求失败

请求百度如下错误

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

处理方式

  • 使用了dio,模拟器和web都没问题,只有desktop不能调接口
  • 需要在macos/Runner/DebugProfile.entitlements文件中添加com.apple.security.network.client。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.security.app-sandbox</key>
	<true/>
	<key>com.apple.security.cs.allow-jit</key>
	<true/>
	<key>com.apple.security.network.server</key>
	<true/>
	<key>com.apple.security.network.client</key>
    <true/>
</dict>
</plist>


posted @ 2023-10-30 17:18  vx_guanchaoguo0  阅读(310)  评论(0编辑  收藏  举报