Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
阿拉莫菲尔';SecTrustCopyKey';仅在iOS 14.0或更新版本中可用_Ios_Swift_Alamofire - Fatal编程技术网

阿拉莫菲尔';SecTrustCopyKey';仅在iOS 14.0或更新版本中可用

阿拉莫菲尔';SecTrustCopyKey';仅在iOS 14.0或更新版本中可用,ios,swift,alamofire,Ios,Swift,Alamofire,我最近添加了pod'Alamofire',“~>5.4.0” 到我的项目,但在服务器TrustEvaluation.swift第603行中有一个错误: return SecTrustCopyKey(createdTrust) //'SecTrustCopyKey' is only available in iOS 14.0 or newer 我怎样才能解决这个问题?是否应该使用早期版本?您可以将该代码包装在一个可用的语句中,如下所示: if #available(iOS 14, *) {

我最近添加了
pod'Alamofire',“~>5.4.0”
到我的项目,但在服务器TrustEvaluation.swift第603行中有一个错误:

return SecTrustCopyKey(createdTrust) //'SecTrustCopyKey' is only available in iOS 14.0 or newer

我怎样才能解决这个问题?是否应该使用早期版本?

您可以将该代码包装在一个可用的语句中,如下所示:

if #available(iOS 14, *) 
{
    return SecTrustCopyKey(createdTrust)
}
else 
{
    // Return something else here.
}
显然,这意味着您将无法在运行较低iOS版本的设备上使用
SecTrustCopyKey()

为该功能找到一个等价物(适用于以前的iOS版本)将是一个解决方案。这可以用在
else{…}

中,谢谢,但我正在寻找的“该函数的等价物”是完整的文档,在那里你应该可以找到任何可用的函数。这很奇怪。刚刚安装了Alamofire 5.4.0,在该文件的这一行中调用了另一个函数:
SecTrustCopyPublicKey(createdTrust)
。是的,这不是Alamofire的代码行。Alamofire根本不使用
SecTrustCopyKey
。你说得对。我不知道为什么会这样。(它的文件被锁定,我确信它没有被更改)。我删除了它,然后又添加了它,它变了!!谢谢