简体   繁体   English

无法在 IOS 模拟器上运行 React Native 项目

[英]Failed to run react native project on IOS Simulator

enter image description here I'm new to react native, I'm following the official React native's website to init a new project, try to run IOS. But, failed with the error below. enter image description here我是 React Native 的新手,我正在关注 React Native 的官方网站来初始化一个新项目,尝试运行 IOS。但是,失败并出现以下错误。 React-Native version 0.59 XCode 10.2 React-Native 版本 0.59 XCode 10.2

error Failed to build iOS project.错误无法构建 iOS 项目。 We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening HelloWorld.xcodeproj我们运行了“xcodebuild”命令,但它以错误代码 65 退出。要进一步调试构建日志,请考虑使用 Xcode.app 构建您的应用程序,方法是打开 HelloWorld.xcodeproj

When I run react-native run-ios --simulator="iPhone 7" Error as below:当我运行 react-native run-ios --simulator="iPhone 7" 错误如下:

info Command PhaseScriptExecution failed with a nonzero exit code

info 

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening HelloWorld.xcodeproj

Starting the simulator : Once you have your React Native project initialized, you can run react-native run-ios inside the newly created project directory.启动模拟器:初始化 React Native 项目后,您可以在新创建的项目目录中运行 react-native run-ios。 If everything is set up correctly, you should see your new app running in the iOS Simulator shortly.如果一切设置正确,您应该很快就会看到您的新应用程序在 iOS 模拟器中运行。 Specifying a device : You can specify the device the simulator should run with the --simulator flag, followed by the device name as a string.指定设备:您可以使用--simulator标志指定模拟器应运行的设备,后跟设备名称作为字符串。 The default is "iPhone X" .默认为"iPhone X" If you wish to run your app on an iPhone 4s, just run react-native run-ios --simulator="iPhone 4s" .如果您希望在 iPhone 4s 上运行您的应用程序,只需运行react-native run-ios --simulator="iPhone 4s"

The device names correspond to the list of devices available in Xcode.设备名称对应于 Xcode 中可用的设备列表。 You can check your available devices by running xcrun simctl list devices from the console.您可以通过从控制台运行xcrun simctl list devices 来检查可用设备。

In my case, I was specifying a simulator, but I had a different simulator open.就我而言,我指定了一个模拟器,但我打开了一个不同的模拟器。 Targeting the one that was opened, or simply closing it fixed the issue.针对打开的那个,或者干脆关闭它可以解决这个问题。

try this and see if it works or not.试试这个,看看它是否有效。

first go to to ios folder of the project in terminal.首先 go 到终端中项目的 ios 文件夹。

for that you can use terminal in visual studio code.为此,您可以在 Visual Studio 代码中使用终端。

cd ios then cd ios然后

pod install

go back (to app directory) cd.. go 返回(到app目录) cd..

npm install

npm start

take a new terminal then, npx react-native run-ios然后使用一个新终端, npx react-native run-ios

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM