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
Ios RestKit RKAttributeMapping fromKeyPath存档错误_Ios_Swift_Restkit_Restkit 0.20 - Fatal编程技术网

Ios RestKit RKAttributeMapping fromKeyPath存档错误

Ios RestKit RKAttributeMapping fromKeyPath存档错误,ios,swift,restkit,restkit-0.20,Ios,Swift,Restkit,Restkit 0.20,我在混合Swift/Obj C项目中使用RestKit 0.26.0。我们正在Swift文件中设置关系映射,当我正常运行或构建项目时,一切正常 但是,当我尝试将应用程序存档以上载分发时,由于RKAttributeMapping和RKRelationshipMapping上的attributeMappingFromKeyPath:toKeyPath:withMapping方法存在问题,存档失败 具体地说,当我存档时,会出现以下错误: '(fromKeyPath: String!, toKeyPat

我在混合Swift/Obj C项目中使用RestKit 0.26.0。我们正在Swift文件中设置关系映射,当我正常运行或构建项目时,一切正常

但是,当我尝试将应用程序存档以上载分发时,由于RKAttributeMapping和RKRelationshipMapping上的attributeMappingFromKeyPath:toKeyPath:withMapping方法存在问题,存档失败

具体地说,当我存档时,会出现以下错误:

'(fromKeyPath: String!, toKeyPath: String!, withMapping: RKMapping!) -> RKRelationshipMapping' is not convertible to '(fromKeyPath: String!, toKeyPath: String!, withMapping: RKMapping!) -> RKRelationshipMapping!'
”(fromKeyPath:String!toKeyPath:String!)->RKAttributeMapping“不能转换为”(fromKeyPath:String!toKeyPath:String!)->RKAttributeMapping!'

对于此代码块:

let errorMapping = RKObjectMapping(forClass: RKErrorMessage.self)
        errorMapping.addPropertyMapping(RKAttributeMapping(fromKeyPath: nil, toKeyPath: "userInfo"));
每当我在其他地方使用attributeMappingFromKeyPath:toKeyPath方法时,我也会遇到相同/非常相似的错误:

mapping.addPropertyMapping(RKRelationshipMapping(fromKeyPath: "(userId).friends", toKeyPath: "friends", withMapping: friendsMapping))
产生以下错误:

'(fromKeyPath: String!, toKeyPath: String!, withMapping: RKMapping!) -> RKRelationshipMapping' is not convertible to '(fromKeyPath: String!, toKeyPath: String!, withMapping: RKMapping!) -> RKRelationshipMapping!'
同样,应用程序在模拟器中构建和运行完全正常,不会引发任何错误或警告。问题就出现在归档过程中。我尝试过所有简单的“常识”解决方案,如清理构建文件夹、删除派生数据等。我在多台计算机上都尝试过,所有这些计算机都做过同样的事情


编辑:刚意识到存档版本使用的版本配置与我的开发版本不同,当我将运行应用程序的版本配置更改为存档中使用的版本配置时,我会收到相同的错误,因此,在构建配置中有一些更改导致了这个问题。

我通过将Swift编译器优化级别从“快速、整个模块”设置为“快速”,解决了这个问题。此设置可在您的构建设置中找到。

我也遇到过此问题,swift优化不允许nil作为fromKeyPath作为字符串传递!默认情况下使用nonull。RKAttributeMapping.h需要将参数设置为可为null,如中所示: +(instancetype)attributeMappingFromKeyPath:(可空NSString*)sourceKeyPath TokePath:(可空NSString*)destinationKeyPath


更改优化级别对我来说也隐藏了问题,如果我找到更好的解决方案,我会发回。

可能这些构建设置之一会使swift编译器在展开方面更加严格?@Wain似乎是一个安全的赌注,我已经尝试过将我的dev config和release config之间构建设置的任何差异更改为release版本以强制失败,但到目前为止还没有成功。