在构建测试时,'意外'@'程序'错误

时间:2017-07-14 08:09:22

标签: objective-c xcode xctest uitest

在我的项目中,我使用的是来自ReactiveCocoa的名为keypath的宏:

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

这与我项目中的问题非常相似。但仍然不同,没有任何有用的答案。 有人有想法如何解决它?因为我真的被困在这里,不知道该搬到哪里。

1 个答案:

答案 0 :(得分:1)

不应将

TokenModel编译到您的测试目标中。测试目标应仅包含测试代码(以及任何需要的库)。

转到测试目标设置。在“测试”部分的“常规”下,确保已指定“主机应用程序”。您可能还需要启用“允许测试主机应用程序API”复选框。

然后从测试目标中删除生产代码。

相关问题