React Native 填坑系列

2021-01-14  本文已影响0人  gyq琪琪

1. 导入RealmJS 报错 database is locked Possibly there are two concurrent builds running in the same filesystem location.

解决方案: Build Phases / Link Binary With Libraries 中导入 libRealmJS.a


WeChat2f104eb32f51b7adb3129125bb82c708.png

2. Make sure you're running a packager server or have included a .jsbundle file in your application bundle.

1. 查看8081端口占用情况
$  lsof -i tcp:8081
2. 杀死相关进程
$ killall -9 node
3. 重启编译器或者电脑

3. React native项目iOS目录 切换swift项目 导致node服务不会自动执行 有两种解决方案:

1. 开启两个终端窗口, 分别执行
$ react-native start
$ react-native run-ios
2. iOS swift项目中添加自动开启node服务的脚本
WechatIMG18.png

脚本中添加如下内容:

     export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}"
     echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react- 
     native/scripts/.packager.env"
     if [ -z "${RCT_NO_LAUNCH_PACKAGER+xxx}" ] ; then
     if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then
     if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then
     echo "Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly"
     exit 2
     fi
     else
     open "$SRCROOT/../node_modules/react-native/scripts/launchPackager.command" || echo "Can't start 
     packager automatically"
     fi
     fi

4. No bundle URL present. Make sure you're running a packager server or have included a .jsbundle file in your application bundle.

command+D 打开调试菜单 -> Configure Bundler -> 配置本机IP地址


WeChat155ad905b7116f202eb33dd2efa24c41.png
上一篇下一篇

猜你喜欢

热点阅读