描述
该应用程序仅在unhandled JS Exception: Invalid regular expression: unrecognized character after (? 未处于调试模式时在 iOS 11.2 上崩溃。我已经在 iOS 13 上测试了相同的代码,它运行良好。我最终找出了导致问题的正则表达式,我发现所有这种类型的正则表达式 (?<value>\d{2}\/\d{2}\/\d{4})都导致了崩溃,它们被存储为单独的 .js 文件中的 Javascript 对象的值。我要求一种不需要更改所有正则表达式的解决方案。
我不明白为什么 iOS 13 上的行为与 iOS 11.2 不同。
此外,我在此链接Crash if not in debug on android and iOS 上发现了与lookbehind regex类似的问题。
我已经尝试过的
环境
System:
OS: macOS 10.15.2
CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
Memory: 461.18 MB / 16.00 GB
Binaries:
Node: 13.3.0 - /usr/local/Cellar/node/13.3.0/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5977832
Xcode: 11.3/11C29 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: ^0.60.5 => 0.60.5
npmGlobalPackages:
react-native-cli: 2.0.1
Run Code Online (Sandbox Code Playgroud)
截图
谢谢阅读
我的建议是,如果您发现它不适用于某些特定的 ios 版本,请检查 ios 版本以及其 ios 13 及更高版本是否使用该正则表达式,或者尝试其他可在 11.2 中使用的正则表达式。
您可以通过以下方式检查 iosVersion
import {Platform} from 'react-native';
const majorVersionIOS = parseInt(Platform.Version, 10);
if (majorVersionIOS <= 13) {
console.log('YOu need some other regex');
} else {
console.log('YOu can use same regex');
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你。如有疑问请放心
| 归档时间: |
|
| 查看次数: |
389 次 |
| 最近记录: |