xcode 项目中缺少main.jsbundle、Foundation和Security,导致报错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41351739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:41:25  来源:igfitidea点击:

main.jsbundle, Foundation and Security missing in the project, causing error

javascriptiosxcodereactjsreact-native

提问by Ilja

I've noticed that file main.jsbundlefile is missing from the project and am not sure of how to fix it, should I delete the file / is there a step I can perform to fix it?

我注意到main.jsbundle项目中缺少文件file 并且不确定如何修复它,我应该删除该文件/是否有我可以执行的步骤来修复它?

Here is a screenshot of where it is in the project:

这是它在项目中的位置的屏幕截图:

enter image description here

在此处输入图片说明

Update:

更新:

Similar issue appears with following frameworks as well

类似的问题也出现在以下框架中

enter image description here

在此处输入图片说明

回答by Pritish Vaidya

The problem can be resolved as follows

问题可以如下解决

  • By using the react nativecommand line
  • $ react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundleusing this in the root of the react native project
  • When the main.jsbundlefile is generated add it back to the Add Files to Projectoption
  • Just verify that the file is included in the build phaseand re-build
  • 通过使用react native命令行
  • $ react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle在本机项目根目录中使用它
  • main.jsbundle文件生成其重新添加到该Add Files to Project选项
  • 只需验证该文件是否包含在构建阶段,然后re-build

UpdateFor the asset destination to be set they have to be in same folder.

更新对于要设置的资产目标,它们必须位于同一文件夹中

Try this,it would create the asset folder

试试这个,它会创建资产文件夹

$ react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle --assets-dest ./ios

回答by sumesh

i am using react-native version- 0.47.1in my case after running the command suggested by @pritishvaidyasolved the main.js bundle issue, but even in release build i could see the yellow warning boxes. So i modified the command by adding --dev false. That did the trick. Leaving this updated command here in case, someone is stuck like me.

在运行@pritishvaidya建议的命令后,我正在使用react-native 版本 - 0.47.1解决了 main.js 包问题,但即使在发布版本中,我也可以看到黄色警告框。所以我通过添加--dev false修改了命令。这就是诀窍。把这个更新的命令留在这里以防万一有人像我一样卡住了。

react-native bundle --entry-file ./index.ios.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ./ios

回答by myself

If you're ejecting from create-react-native-appon react-native v0.50+ the index.ios.jsand index.android.jsfiles are now combined into index.js

如果您从create-react-native-appreact-native v0.50+ 中弹出,则index.ios.jsindex.android.js文件现在合并为index.js

Before or after ejecting run

在弹出运行之前或之后

npm i -g react-native-cliif you npm install

npm i -g react-native-cli如果你 npm install

or

或者

yarn global add react-native-cliif you yarn install

yarn global add react-native-cli如果你 yarn install

...After Ejecting...

...弹出后...

[bad advice]run react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle. <-- Do Not do this.

[不好的建议]运行react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle。<-- 不要这样做。

[UPDATE] The main.jsbundle is created when xcode opens the terminal bundler. make sure you don't close the terminal window and it will run fine.

[更新] main.jsbundle 在 xcode 打开终端打包器时创建。确保您没有关闭终端窗口,它会运行良好。

回答by ConfusedDev

I'm on a mac. I'm new to react native, I had the same issue. After 2 hours of trying everything suggested, I solved it. I realised that you need to first start it on a different tab inside the terminal and then run the command "react-native run-ios". So if you still have problems, open terminal, have 2 tabs open. 1) First cd to your project and enter "npm run start". 2) Then go the second tab and enter "react-native run-ios". That should do it.

我在 mac 上。我是本机反应的新手,我遇到了同样的问题。在尝试了所有建议的 2 小时后,我解决了它。我意识到您需要首先在终端内的不同选项卡上启动它,然后运行命令"react-native run-ios"。因此,如果您仍有问题,请打开终端,打开 2 个选项卡。1) 首先 cd 到您的项目并输入"npm run start". 2)然后转到第二个选项卡并输入"react-native run-ios"。那应该这样做。

If you have problems with "react-native run-android"then you should have its simulator open beforehand. Open a third tab and go to ~/Library/Android/sdk/tools, then enter "./emulator -list-avds"to see your installed android simulators, then start one with "./emulator -avd {your-emulator-name}". When you are done, hit "react-native run-android".

如果你有问题,"react-native run-android"那么你应该事先打开它的模拟器。打开第三个选项卡并转到~/Library/Android/sdk/tools,然后输入 "./emulator -list-avds"以查看已安装的 android 模拟器,然后以"./emulator -avd {your-emulator-name}". 完成后,点击"react-native run-android"