2017-05-12 94 views
1

所以我是相當新的反應本機和移動開發的一般情況下,這個錯誤不斷出現,失敗的測試文件是由Facebook提供的標準生成文件反應本地構建。RCTSharedApplication()委託錯誤反應原生

這裏的測試:

- (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模擬器,所以我真的不知道是什麼問題,明顯的答案可能只是刪除測試。不過,我對可能的原因感興趣,歡呼。

回答