React Native项目遭遇Unhandled JS Exception及CoreTelephony连接异常求助
React Native 跨平台运行时持续报错的解决方案求助
错误日志
2022-07-25 14:25:05.002891+0300 FitAndMore[78006:725830] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.} 2022-07-25 14:25:05.003619+0300 FitAndMore[78006:725856] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.} 2022-07-25 14:25:05.007068+0300 FitAndMore[78006:725856] [Client] Synchronous remote object proxy returned error: Er2022-07-25 14:25:05.007332+0300 FitAndMore[78006:725833] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.} ror Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.} 2022-07-25 14:25:05.025844+0300 FitAndMore[78006:725830] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.} 2022-07-25 14:25:05.025844+0300 FitAndMore[78006:725856] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.} 2022-07-25 14:25:05.050572+0300 FitAndMore[78006:725829] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.} 2022-07-25 14:25:05.055166+0300 FitAndMore[78006:725829] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.} WARNING: Logging before InitGoogleLogging() is written to STDERR E0725 14:25:06.978281 75517952 NativeToJsBridge.cpp:188] Attempting to call JS function on a bad application bundle: RCTLog.logIfNoNativeHook() Unhandled JS Exception: Unexpected number '.5' no stack
项目package.json配置
{ "name": "Youhanna", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "expo start --dev-client", "test": "jest", "lint": "eslint ." }, "dependencies": { "@expo/vector-icons": "^12.0.5", "@react-native-async-storage/async-storage": "^1.15.11", "@react-native-community/cli": "^6.2.0", "@react-native-community/clipboard": "^1.5.1", "@react-native-community/datetimepicker": "^3.5.2", "@react-native-community/netinfo": "^7.1.2", "@react-native-community/viewpager": "^5.0.11", "@react-native-firebase/admob": "^11.5.0", "@react-native-firebase/app": "^11.5.0", "@react-native-firebase/messaging": "^11.5.0", "@react-native-masked-view/masked-view": "^0.2.6", "@react-native-picker/picker": "^2.2.1", "@react-native/normalize-color": "^2.0.0", "@react-navigation/drawer": "^6.1.8", "@react-navigation/native": "^6.0.6", "@react-navigation/stack": "^6.0.11", "axios": "^0.24.0", "core-js": "^3.19.1", "error-stack-parser": "^2.0.6", "expo": "~43.0.3", "expo-app-loading": "^1.2.1", "expo-av": "^10.1.3", "expo-calendar": "^10.0.3", "expo-clipboard": "~2.0.3", "expo-constants": "^12.1.3", "expo-device": "^4.0.3", "expo-file-system": "^13.0.3", "expo-image-manipulator": "~10.1.2", "expo-image-picker": "^11.0.3", "expo-linear-gradient": "^10.0.3", "expo-localization": "^11.0.0", "expo-permissions": "^13.0.3", "expo-screen-orientation": "~4.0.3", "expo-sharing": "^10.0.3", "expo-splash-screen": "^0.13.5", "expo-status-bar": "^1.1.0", "expo-updates": "~0.10.13", "firebase": "^9.5.0", "i18n-js": "^3.8.0", "jsonfile": "^6.1.0", "lodash.memoize": "^4.1.2", "lottie-ios": "~3.2.3", "lottie-react-native": "~5.0.0", "moment": "^2.29.1", "native-base": "^2.15.2", "package": "^1.0.1", "prop-types": "^15.7.2", "react": "17.0.1", "react-animated-css": "^1.2.1", "react-dom": "^17.0.2", "react-native": "0.64.3", "react-native-animatable": "^1.3.3", "react-native-app-intro-slider": "^4.0.4", "react-native-appearance": "^0.3.4", "react-native-calendars": "^1.1269.0", "react-native-codegen": "^0.0.11", "react-native-credit-card-input": "^0.4.1", "react-native-crypto-js": "^1.0.0", "react-native-datepicker": "^1.7.2", "react-native-device-info": "^8.4.8", "react-native-drawer": "^2.5.1", "react-native-dropdownalert": "^4.3.0", "react-native-easy-content-loader": "^0.3.2", "react-native-easy-grid": "^0.2.2", "react-native-elements": "^3.4.2", "react-native-event-listeners": "^1.0.7", "react-native-fs": "^2.18.0", "react-native-gesture-handler": "^1.10.3", "react-native-image-picker": "^4.3.0", "react-native-image-resizer": "^1.4.5", "react-native-image-slider-show": "^1.0.3", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.5.6", "react-native-localize": "^2.1.5", "react-native-map-link": "^2.8.1", "react-native-material-dropdown-v2": "^0.11.1", "react-native-material-textfield": "^0.16.1", "react-native-modal": "^13.0.0", "react-native-navigation-apps": "^1.0.27", "react-native-open-maps": "^0.4.0", "react-native-otp-textinput": "^0.0.8", "react-native-paper": "^4.10.1", "react-native-permissions": "~3.1.0", "react-native-photo-upload": "^1.3.0", "react-native-reanimated": "~2.3.1", "react-native-render-html": "^6.3.0", "react-native-responsive-screen": "^1.4.2", "react-native-root-toast": "^3.3.0", "react-native-router-flux": "^4.3.1", "react-native-safe-area-context": "^3.3.2", "react-native-screens": "~3.9.0", "react-native-signature-canvas": "^4.3.0", "react-native-skeleton-placeholder": "^5.0.0", "react-native-snap-carousel": "^3.9.1", "react-native-star-rating": "^1.1.0", "react-native-svg": "^12.1.1", "react-native-swiper": "^1.6.0", "react-native-swiper-flatlist": "^3.0.16", "react-native-tab-view": "^3.1.1", "react-native-tiny-toast": "^1.0.7", "react-native-vector-icons": "^9.0.0", "react-native-walkthrough-tooltip": "^1.3.0", "react-native-web": "^0.17.5", "react-native-webview": "^11.14.3", "react-native-youtube-iframe": "^2.2.1", "react-navigation": "^4.4.4", "react-navigation-drawer": "^2.7.1", "react-navigation-stack": "^2.10.4", "react-redux": "^7.2.6", "react-select-3ilogics": "^0.1.1", "react-swiper-3ilogics": "^0.1.0", "redux": "^4.1.2", "redux-logger": "^3.0.6", "redux-persist": "^6.0.0", "rn-expo-paypal-integration": "^1.2.0", "tcomb-form-native": "^0.6.20" }, "devDependencies": { "@babel/core": "~7.16.0", "@babel/runtime": "~7.16.3", "@react-native-community/eslint-config": "^3.0.1", "babel-jest": "^27.3.1", "jest": "^27.3.1", "metro-react-native-babel-preset": "~0.66.2", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } }
已尝试的操作
- 重新创建项目
- 清除项目缓存
- 执行
npm i --force - 重新执行
pod install(iOS端)
解决方案
1. 处理JS核心错误:Unexpected number '.5'
这个错误是JS语法或数据解析异常,根源是代码中出现了无法识别的独立.5(正确写法应为0.5),可按以下步骤排查:
- 全局搜索项目代码中的
.5,检查样式、计算逻辑、API数据处理等场景是否存在遗漏前缀0的数字 - 校验API接口返回的JSON数据,确认是否有格式错误的数字字段,在接收数据时添加格式化处理逻辑
- 开启React Native远程调试模式(Debug JS Remotely),尝试捕获更详细的错误栈以定位出错文件和行号
- 排查第三方库使用,比如
react-native-render-html渲染富文本、moment日期处理时是否触发异常
2. 缓解iOS系统层面的XPC连接错误
com.apple.commcenter.coretelephony.xpc错误属于iOS系统XPC服务连接异常,可尝试:
- 切换至不同版本的iOS模拟器测试,或更新模拟器到最新版本
- 真机测试时重启设备并重新安装应用
- 检查
react-native-device-info等调用CoreTelephony的库,确认Info.plist中是否添加了必要的权限描述(若使用蜂窝数据相关功能) - 升级
react-native-device-info到兼容React Native 0.64的最新版本,修复旧版本的系统API调用问题
3. 解决依赖冲突问题
从package.json可见项目存在多版本依赖冲突,需清理整合:
- 移除
react-navigationv4系列依赖(react-navigation、react-navigation-drawer、react-navigation-stack),统一使用@react-navigation/nativev6版本 - 删除冗余依赖,比如同时安装的
expo-clipboard和@react-native-community/clipboard,保留一个即可 - 执行
npm dedupe整理依赖树,消除版本冲突 - 删除
node_modules、package-lock.json、iOSPods目录和Podfile.lock,重新执行npm install和pod install
内容的提问来源于stack exchange,提问作者Rabia Abu Hanna
相关产品推荐
相关产品推荐

