macOS 工程报错 Error: Error Domain=NSPOSIXErrorDomain Code=1 「Operation not permitted」

在 macOS 工程中调试接口时出现报错:

1
2
3
Error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E0BD2CC5-BC74-4624-A308-020EECDC00AE>.<1>, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=1, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <E0BD2CC5-BC74-4624-A308-020EECDC00AE>.<1>"
), _NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, proxy, uses wifi}

解决办法:

在「TARGETS - Singin & Capabilities」中找到 App Sandbox,勾选:

  • Incoming Connections (Server)
  • Outgoing Connections (Client)

如图所示:

参考:

  1. NSPOSIXErrorDomain when binding to socket on macOS 10.12
  2. Error while binding a socket : NSPOSIXErrorDomain Code=1 “Operation not permitted”

macOS 工程报错 Error: Error Domain=NSPOSIXErrorDomain Code=1 「Operation not permitted」
https://wonderhoi.com/2024/12/02/macOS-工程报错-Error-Error-Domain-NSPOSIXErrorDomain-Code-1-「Operation-not-permitted」/
作者
wonderhoi
发布于
2024年12月2日
许可协议