Max*_*hke 4 c++ objective-c ios react-native
我有一个React Native项目仍在运行0.40.0,当我尝试在XCode for Simulator中构建时:
Ordered comparison between pointer and zero ('NSNumber *' and 'int')
这是文件中RCTJavaScriptLoader.mm的React.xcodeproj> React>Base
因为此错误发生在React Native文件中,所以我不知道它试图告诉我什么。代码块是:
- (NSString *)description
{
NSMutableString *desc = [NSMutableString new];
[desc appendString:_status ?: @"Loading"];
if (_total > 0) { // ERROR HAPPENS HERE
[desc appendFormat:@" %ld%% (%@/%@)", (long)(100 * [_done integerValue] / [_total integerValue]), _done, _total];
}
[desc appendString:@"\u2026"];
return desc;
}
Run Code Online (Sandbox Code Playgroud)
我试图清理项目,甚至删除了ios文件夹并通过使用react-native upgrade对其进行了重新生成,但在链接所有内容后它无济于事。
问题的解释:
if (_total > 0)=> if ([_total integerValue] > 0)因为_total是NSNumber。有关SO的相关问题。
对于剩下的,这是关于React-Native的一个问题,该问题自1月3日以来已在该commit上解决。根据提交,然后应将其固定在版本> = v0.51.0-rc.3上,并且仍应将其固定在当前版本上(无回归)。
建议然后更新您的React版本。