xcode React Native ios 构建在 react-native run-ios 上失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43391417/
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:54:49  来源:igfitidea点击:

React Native ios build failed on react-native run-ios

iosxcodereact-nativeterminal

提问by furball514

getting this error

收到这个错误

** BUILD FAILED **

The following build commands failed: CompileC /Users/karthikn/AwesomeProject/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTTabBarItem.o Views/RCTTabBarItem.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure)

Installing build/Build/Products/Debug-iphonesimulator/AwesomeProject.app An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2): Failed to install the requested application An application bundle was not found at the provided path. Provide a valid path to the desired application bundle. Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/AwesomeProject.app/Info.plist Print: Entry, ":CFBundleIdentifier", Does Not Exist

** 构建失败 **

以下构建命令失败:CompileC /Users/karthikn/AwesomeProject/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTTabBarItem.o Views/RCTTabBarItem.m normal x86_64 Objective-c com.apple.compilers.llvm.clang.1_0.compiler(1 次失败)

安装 build/Build/Products/Debug-iphonesimulator/AwesomeProject.app 处理命令时遇到错误 (domain=NSPOSIXErrorDomain, code=2):无法安装请求的应用程序 在提供的路径中找不到应用程序包。提供所需应用程序包的有效路径。打印:条目,“:CFBundleIdentifier”,不存在

命令失败:/usr/libexec/PlistBuddy -c 打印:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/AwesomeProject.app/Info.plist 打印:条目,“:CFBundleIdentifier”,不存在

回答by thai huynh

Xcode 8.2 still occur same error. Three lines bellow fixed it for me :) Downgrade react(16.0.0-alpha.12 -> 16.0.0-alpha.6) & react-native(0.45.0 -> 0.44.0)
rm -rf node_modules/react
npm i [email protected]-S
npm i [email protected]-S
Then run react-native run-ios

Xcode 8.2 仍然出现同样的错误。下面三行为我修复了它:) 降级 react(16.0.0-alpha.12 -> 16.0.0-alpha.6) & react-native(0.45.0 -> 0.44.0)
rm -rf node_modules/react
npm i [email protected]-S
npm i [email protected]-S
然后运行react-native run-ios

回答by Floris M

If it's your first project, you may have the same problem than me: do NOT use space in your project path!

如果这是您的第一个项目,您可能会遇到与我相同的问题:不要在项目路径中使用空间!

回答by Mukesh Kumar

Try sudo react-native run-ios This helped me

试试 sudo react-native run-ios 这对我有帮助

回答by Carlos Eduardo da Silva

There are different problems that cause this issue. I'll post here what I did to resolve in my case.

有不同的问题会导致此问题。我会在这里发布我为解决我的案例所做的事情。

1 - Delete the folder node_modules and the folders of android and ios from project root:

1 - 从项目根目录中删除文件夹 node_modules 和 android 和 ios 文件夹:

rm -rf node_modules/ ios/ android/

2 - Rebuild the folders:

2 - 重建文件夹:

npm install && react-native upgrade

or (If you have used yarn in the project)

或者(如果你在项目中使用过yarn)

yarn install && react-native upgrade 

3 - After that, just run the command again:

3 - 之后,只需再次运行命令:

react-native run-ios 

or

或者

react-native run-android.

I hope it helped =)

我希望它有帮助 =)

回答by eric-vandenberg

There's a good chance you're running an outdated version of React-Native and your template is no longer compatible.

您很有可能正在运行一个过时的 React-Native 版本,并且您的模板不再兼容。

There are instructionsprovided on ways to upgrade.

说明书提供的方法进行升级。

The simplest would be to run react-native upgradeand you'll be prompted with files react-native wants to overwrite. Clicking yes through all the prompts solved this issue for me but if you're concerned about losing any changes, it's recommended to install npm install -g react-native-git-upgradeand merge any conflicts after running react-native-git-upgrade

最简单的方法是运行react-native upgrade,系统会提示您 react-native 想要覆盖的文件。在所有提示中单击“是”为我解决了这个问题,但如果您担心丢失任何更改,建议npm install -g react-native-git-upgrade在运行后安装并合并任何冲突react-native-git-upgrade

回答by Lalit kumar

Check this In Your info.plist Bundle identifier

检查这个 In Your info.plist Bundle identifier

Or Add this Bundle identifier name as --> com.cmpname.yourapp // change name according

或将此捆绑包标识符名称添加为 --> com.cmpname.yourapp // 根据更改名称

enter image description here

在此处输入图片说明

回答by Nimish Patel

DO NOT use space in project path. It had solved my problem.

不要在项目路径中使用空格。它解决了我的问题。

回答by Meghs Dhameliya

Replace Boost C++ Libraries with this one Download Link

用这个下载链接替换 Boost C++ 库

/node_modules/react-native/third-party/boost_1_63_0

/node_modules/react-native/第三方/boost_1_63_0

回答by Anindya Mukherjee

seems like there is an issue with the react-native version, downgrading the version will resolve the issue. Use the following commands:

似乎 react-native 版本存在问题,降级版本将解决该问题。使用以下命令: