React native插件项目iOS中讯飞报错Assertion failed: (severity >= 0 && severity < NUM_SEVERITIES), function SetLogDestination

https://github.com/zphhhhh/react-native-speech-iflytek/issues/36

描述:
[IFlySpeechUtility createUtility:initString]的时候报错:

Assertion failed: (severity >= 0 && severity < NUM_SEVERITIES), function SetLogDestination,
file /Users/samyao/Git/trace/node_modules/react-native/third-party/glog-0.3.4/src/logging.cc, line 595.

解决办法:

inline void LogDestination::SetLogDestination(LogSeverity severity,
                          const char* base_filename) {
//  assert(severity >= 0 && severity < NUM_SEVERITIES);
    char* base_filename_copy = nullptr;                      //初始化char*类型
    base_filename_copy = const_cast<char*>(base_filename);   //const char*类型转char*类型
    if (severity >= 0 && severity < NUM_SEVERITIES) {
      //
    } else {
      severity = 0;
      base_filename_copy = const_cast<char*>("glogTest");
    }
  // Prevent any subtle race conditions by wrapping a mutex lock around
  // all this stuff.
  MutexLock l(&log_mutex);
  //log_destination(severity)->fileobject_.SetBasename(base_filename);
    log_destination(severity)->fileobject_.SetBasename(base_filename_copy);
    
}
原文地址:https://www.cnblogs.com/Oldz/p/13343683.html