1. 導(dǎo)入RealmJS 報(bào)錯(cuò) database is locked Possibly there are two concurrent builds running in the same filesystem location.
解決方案: Build Phases / Link Binary With Libraries 中導(dǎo)入 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. 殺死相關(guān)進(jìn)程
$ killall -9 node
3. 重啟編譯器或者電腦
3. React native項(xiàng)目iOS目錄 切換swift項(xiàng)目 導(dǎo)致node服務(wù)不會(huì)自動(dòng)執(zhí)行 有兩種解決方案:
1. 開啟兩個(gè)終端窗口, 分別執(zhí)行
$ react-native start
$ react-native run-ios
2. iOS swift項(xiàng)目中添加自動(dòng)開啟node服務(wù)的腳本

WechatIMG18.png
腳本中添加如下內(nèi)容:
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 打開調(diào)試菜單 -> Configure Bundler -> 配置本機(jī)IP地址

WeChat155ad905b7116f202eb33dd2efa24c41.png