2016-03-29 28 views
3

我在一个混合的Swift/Obj C项目中使用RestKit 0.26.0。我们正在Swift文件中建立关系映射,当我正常运行或构建项目时,一切正常。RestKit RKAttributeMapping fromKeyPath错误归档

但是,当我尝试归档应用程序以上载以进行分发时,由于与RKAttributeMapping和RKRelationshipMapping中的attributeMappingFromKeyPath:toKeyPath:withMapping方法有关的问题,存档失败。

具体而言,当我存档,我得到这个错误:

'(fromKeyPath: String!, toKeyPath: String!) -> RKAttributeMapping' is not convertible to '(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!' 

此外,应用程序生成并运行在模拟器完全没问题,用了引发任何错误或警告。它只是在归档期间出现问题。我已经尝试了所有简单的'常识'解决方案,如清理生成文件夹,删除派生数据等。我已经在多台计算机上尝试过它,并且它们都做同样的事情。

编辑:只是意识到,存档构建使用不同的构建配置比我的开发构建,当我更改运行应用程序的构建配置,以使用相同的存档,我得到相同的错误,所以有简单的东西在造成问题的构建配置中更改。

+0

的那些构建设置大概一个使迅速编译器更加严格展开? – Wain

+0

@Wain看起来像是一个安全的赌注,我尝试过并改变了我的开发配置和发布配置之间的构建设置与发布版本之间的任何差异,以强制失败,但目前为止没有骰子。 –

回答

2

我从快,整个模块设置斯威夫特编译器优化级别,只是快速的解决了该问题。此设置可在您的构建设置中找到。

2

我也遇到了这个,迅速优化不允许零作为一个fromKeyPath传递,因为它是字符串!默认情况下为非零。 RKAttributeMapping.h需要使参数为空,如下所示: +(instancetype)attributeMappingFromKeyPath :(可为空的NSString *)sourceKeyPath toKeyPath:(可为空的NSString *)destinationKeyPath;

更改优化级藏了我的问题,以及,我会后回来,如果我找到一个更好的解决方案