react-native run-ios出错,报找不到iPhone模拟器

1️⃣常用命令

1. 查看当前可用的所有设备/模拟器列表:

在终端中输入xcrun simctl list devices

2. iPhone模拟器启动(下次启动会默认使用最后一次选择设备,直接启动 react-native run-ios 即可):

react-native run-ios --simulator "iPhone 7 Plus”

3. 使用真机运行项目:
  • 使用真机运行之前需要安装一个软件,打开终端输入以下命令
    npm i -g ios-deploy
    安装完成之后,输入以下命令
    react-native run-ios --device "'wo's iPhone X"
    真机名字可以从Xcode的设备列表打开查看对应的名字或者手机->设置->关于手机查看设备名

(网上查到的但是现版本不存在)
注:这是一个react native的bug:需要将:node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js文件的: // Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc) if (!version.startsWith('iOS') && !version.startsWith('tvOS')) { continue; }修改成: // Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc) if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) { continue; }

react-native run-ios出错,报找不到iPhone X模拟器最好直接yongXcode启动吧,这命令查了好久没解决。

2️⃣可能报错

2.1 Print: Entry, “:CFBundleIdentifier”, Does Not Exist

Installing build/Build/Products/Debug-iphonesimulator/awesome.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/awesome.app/Info.plist
Print: Entry, “:CFBundleIdentifier”, Does Not Exist

解决方法 执行如下命令:
1. react-native upgrade
2. react-native run-ios

2.2 Unrecognized font family ‘Ionicons

在项目根目录执行
1. npm link react-native-vector-icons
2. react-native link react-native-vector-icons
3. yarn add react-native-elements (or) npm i react-native-elements --save

2.3 Unable to resolve module ‘react-native-vector-icons/FontAwesome’

在项目根目录执行
1. yarn add react-native-vector-icons
2. react-native start --reset-cache

2.4 用web storm 运行react-native 工程时,出错:xcrun: error: unable to find utility “instruments”, not a developer tool or in PATH

解决方法:在 终端执行如下命令 sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/

2.5 报错 No bundle url present

解决办法: 删除项目文件下的build文件夹,再次执行 react-native run-ios
1. cd 目录/ios
2. rm -r build
3. react-native run-ios
这个错误有时重新运行一遍就好了

你可能感兴趣的:(react-native run-ios出错,报找不到iPhone模拟器)