当我运行一个react-native项目时,我得到一个错误,没有bundle URL,但我不知道我做了什么错误,我很困惑。
当前回答
步骤1: 在xcode中打开。xcodeworkspace项目,通过“Terminal”导航, “开放/ ios /。xcodeworkspace"按Enter键。
步骤2: 删除主机。Jsbundle文件
步骤3: 回到VS Code,输入这个, React-native bundle——entry-file index.js——platform ios——dev false——bundle-output ios/main。Jsbundle——assets-dest ios
这将生成新的主线。jsbundle文件。
步骤4: react-native run-ios
你不会再次看到错误
其他回答
我正在运行iOS模拟器,这个方法有效:
1. 清理本地项目
1.a For Android项目
cd android
gradlew clean
1.b用于iOS项目
cd ios
xcodebuild clean
2. 清理你的反应物贮藏
2.a如果你正在使用npm
npm start -- --reset-cache
2.b如果你用的是纱线
yarn cache clean
之后,您可以再次运行您的项目。
我也遇到了同样的问题,我通过在AppDelegate中进行更改来解决它。m文件。我改变了
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
to
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
这对我来说很有效:)
我尝试了下面所有的解决方案,但都不起作用:
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。
Mcafee Macbook用户:
Sudo launchctl remove com.mcafee.agent.macmn
步骤1: 在xcode中打开。xcodeworkspace项目,通过“Terminal”导航, “开放/ ios /。xcodeworkspace"按Enter键。
步骤2: 删除主机。Jsbundle文件
步骤3: 回到VS Code,输入这个, React-native bundle——entry-file index.js——platform ios——dev false——bundle-output ios/main。Jsbundle——assets-dest ios
这将生成新的主线。jsbundle文件。
步骤4: react-native run-ios
你不会再次看到错误
推荐文章
- 如何删除默认的导航栏空间在SwiftUI导航视图
- 如何配置历史记录?
- 在react native中隐藏/显示组件
- 如何在iOS中使用Swift编程segue
- Swift -整数转换为小时/分钟/秒
- Swift:声明一个空字典
- React钩子:从回调中访问最新状态
- 在成功提交我的应用程序后,“太多符号文件”
- 首先添加一个UIView,甚至是导航栏
- 我如何改变UIButton标题颜色?
- 在Swift中如何调用GCD主线程上的参数方法?
- NSLayoutConstraints是可动画的吗?
- iOS -构建失败,CocoaPods无法找到头文件
- React-Native:应用程序未注册错误
- 禁用react native按钮