解决"Connection failed (OS Error: Operation not permitted, errno = 1), address = www.itying.com, port = 80"的问题

出现场景

在iphone和macos上运行Flutter APP,出现以下错误。

 

使用网络图片无法正常加载:如下图所示

 

 

 

解决方案

根据错误信息,发现是没有网络权限,申请网络权限就行。
在macos/Runner/目录下,找到DebugProfile.entitlements和ReleaseProfile.entitlements,加入以下配置。

<?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/>
</dict>
</plist>

 

 最后完美解决:上图

 

posted @ 2022-10-18 10:28  学富五车  阅读(515)  评论(0编辑  收藏  举报