2016-03-29 30 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;

更改優化級藏了我的問題,以及,我會後回來,如果我找到一個更好的解決方案