所以我对一般的本机和移动开发做出了相当新的反应,这个错误不断出现,有问题的测试文件是由Facebook提供的标准生成文件,具有反应原生构建。
以下是测试:
- (void)testRendersWelcomeScreen
{
UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO;
__block NSString *redboxError = nil;
RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
if (level >= RCTLogLevelError) {
redboxError = message;
}
});
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
return YES;
}
return NO;
}];
}
RCTSetLogFunction(RCTDefaultLogFunction);
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
}
这是错误:
redacted/ios/ProjectTests/Project.m:40:29: error: bad receiver type 'int'
UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
该应用程序似乎实际上在iOS模拟器中编译和工作,所以我不确定问题是什么,显而易见的答案可能只是删除测试。但是我对可能的原因感兴趣,欢呼。
答案 0 :(得分:0)
尝试重新安装依赖项:
$ rm -rf node_modules
$ npm i
我有同样的问题,它对我有用,因为我之前已经降级了一些不同分支的libs(检查:https://github.com/facebook/react-native/issues/13901)。