2017-07-14 39 views
1

在我的項目,我用微距叫的keyPath從ReactiveCocoa:’意外」 @同時建立測試

NSString *lowercaseStringPath = @keypath(NSString.new, lowercaseString); 
// => @"lowercaseString" 

* @endcode 
* 
* ... the macro returns an \c NSString containing all but the first path 
* component or argument (e.g., @"lowercaseString.UTF8String", @"version"). 
* 
* In addition to simply creating a key path, this macro ensures that the key 
* path is valid at compile-time (causing a syntax error if not), and supports 
* refactoring, such that changing the name of the property will also update any 
* uses of \@keypath. 
*/ 
#define keypath(...) \ 
    metamacro_if_eq(1, metamacro_argcount(__VA_ARGS__))(keypath1(__VA_ARGS__))(keypath2(__VA_ARGS__)) 

#define keypath1(PATH) \ 
    (((void)(NO && ((void)PATH, NO)), strchr(# PATH, '.') + 1)) 

#define keypath2(OBJ, PATH) \ 
    (((void)(NO && ((void)OBJ.PATH, NO)), # PATH)) 

它工作正常使用的主要對象。但是,當我嘗試運行測試,它表明我這個錯誤: enter image description here

我看到this post

這是我的項目非常相似的問題。但仍然不同,並沒有有用的答案。 有沒有人有想法如何解決它?因爲我真的被困在這裏,不知道在哪裏移動。

+0

測試目標中的'TokenModel'以及您的主要目標? –

+0

是的,當然,我已經包括它。 –

回答

1

TokenModel不應編譯到您的測試目標中。測試目標應該只包含測試代碼(以及任何需要的庫)。

轉到您的測試目標設置。在「測試」部分的「常規」下,確保您已指定「主機應用程序」。您可能還需要啓用「允許測試主機應用程序API」複選框。

然後從您的測試目標中刪除生產代碼。