当我运行一个react-native项目时,我得到一个错误,没有bundle URL,但我不知道我做了什么错误,我很困惑。
当前回答
我尝试了下面所有的解决方案,但都不起作用:
Sudo xcodebuild -license或 使用rm -r build删除build文件夹并运行react-native run-ios或 NPM启动并运行react-native run-ios 添加NSAppTransportSecurity到localhost
我是这样解决的:
打开主机文件sudo vi /private/etc/hosts(如果你使用VSCode,使用这个sudo code /private/etc/hosts) 如果不存在,添加三行
127.0.0.1 localhost
255.255.255.255 localhost
::1 localhost
再次运行react-native Run -ios。
其他回答
我尝试了下面所有的解决方案,但都不起作用:
Sudo xcodebuild -license或 使用rm -r build删除build文件夹并运行react-native run-ios或 NPM启动并运行react-native run-ios 添加NSAppTransportSecurity到localhost
我是这样解决的:
打开主机文件sudo vi /private/etc/hosts(如果你使用VSCode,使用这个sudo code /private/etc/hosts) 如果不存在,添加三行
127.0.0.1 localhost
255.255.255.255 localhost
::1 localhost
再次运行react-native Run -ios。
在我的情况下,我不小心从Xcode的构建阶段删除了这个脚本。
所以,一定要有这个脚本。如果没有,只需点击“+”&选择“新建运行脚本阶段”,然后粘贴以下代码。
export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh
确保你的项目中有.jsbundle
Add
react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios
在react原生代码中 尝试重新打开项目
首先关闭模拟器,然后在终端上运行这些程序
npm install
react-native run-ios
在我的情况下,终端抛出绝对没有错误,问题是我的mac的vpn连接,所以我不得不断开vpn,问题得到了解决。
推荐文章
- 如何在iOS中使用Swift编程segue
- Swift -整数转换为小时/分钟/秒
- Swift:声明一个空字典
- React钩子:从回调中访问最新状态
- 在成功提交我的应用程序后,“太多符号文件”
- 首先添加一个UIView,甚至是导航栏
- 我如何改变UIButton标题颜色?
- 在Swift中如何调用GCD主线程上的参数方法?
- NSLayoutConstraints是可动画的吗?
- iOS -构建失败,CocoaPods无法找到头文件
- React-Native:应用程序未注册错误
- 禁用react native按钮
- CFNetwork SSLHandshake iOS 9失败
- 请求失败:不可接受的内容类型:文本/html使用AFNetworking 2.0
- 缺少推荐的图标文件-该包不包含iPhone / iPod Touch的应用程序图标,像素为“120x120”,png格式