create-react-native-app: `npm run ios` error: Failed to start simulator: Process exited with non-zero code: 22

Description

Can’t run my app on iOS simulator. It starts, but keep frozen on the default iOS screen, instead of keep loading and then show my app.

Expected Behavior

Expected to see my app on iOS Simulator once I ran npm run ios.

Observed Behavior

Ran npm run ios and got an error: Failed to start simulator: Error: Process exited with non-zero code: 22

$ npm run ios

> FlatApp@7.0.0 ios /app/demo
> react-native-scripts ios

Starting packager...
Starting simulator...
Failed to start simulator:

Error: Process exited with non-zero code: 22

Exiting...

Also tried with yarn and got the same error:

$ yarn run ios

yarn run v0.23.2
$ react-native-scripts ios 
Starting packager...
Starting simulator...
Failed to start simulator:

Error: Process exited with non-zero code: 22

Exiting...
✨  Done in 20.68s.

Also found this log /Users/user1/Library/Logs/CoreSimulator/999FEB61-817B-4606-8C69-F0F7C6D05BF0/system.log:

Apr 13 00:08:52 aper CoreSimulatorBridge[2540]: Error in registering callback port Error
Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo
{NSLocalizedDescription=Unable to register pasteboard callback port.,
NSLocalizedFailureReason=Port is invalid.}

I’m not running any kind of firewall, in case you’re curious about Port is invalid.

Also tried the procedure Simulator > Reset Content and Settings as described on https://github.com/react-community/create-react-native-app/issues/62 and https://github.com/react-community/create-react-native-app/issues/67, but didn’t work.

Environment

This is my environment. Please, let me know if you would like to check something else.

  • npm ls react-native-scripts: react-native-scripts@0.0.2
  • npm ls react-native: react-native@0.42.3
  • npm ls expo: expo@15.1.3
  • node -v: v7.9.0
  • npm -v: 4.2.0, also tried with 4.4.4
  • yarn --version: 0.23.2
  • watchman version: {"version": "4.7.0"}
  1. Operating system: macOS 10.12.4
  2. Phone/emulator/simulator & version: iOS Simulator 10.0
  3. XCode: 8.2.1, also tried with 8.3.1

Reproducible Demo

user1:demo user1$ npm install -g create-react-native-app
/usr/local/bin/create-react-native-app -> /usr/local/lib/node_modules/create-react-native-app/build/index.js
/usr/local/lib
└── create-react-native-app@0.0.6 

user1:demo user1$ cd ..
user1:app user1$ create-react-native-app my-app
Creating a new React Native app in /app/my-app.

Installing packages. This might take a couple minutes.
Installing react-native-scripts...

yarn add v0.23.2
info No lockfile found.
[1/4] 🔍  Resolving packages...
warning react-native-scripts > xdl > node-uuid@1.4.8: Use uuid module instead
warning react-native-scripts > xdl > auth0-js > xtend > object-keys@0.4.0: 
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 376 new dependencies.
...
✨  Done in 44.05s.
Installing dependencies using yarnpkg...

yarn install v0.23.2
[1/4] 🔍  Resolving packages...
warning react-native > xcode > node-uuid@1.4.7: Use uuid module instead
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
✨  Done in 63.10s.


Success! Created my-app at /app/my-app
...
user1:app user1$ cd my-app/
user1:my-app user1$ yarn run ios
yarn run v0.23.2
$ react-native-scripts ios 
Starting packager...
Starting simulator...
Failed to start simulator:

Error: Process exited with non-zero code: 22

Exiting...
✨  Done in 26.04s.
user1:my-app user1$

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (2 by maintainers)

Most upvoted comments

Found that “Command Line Tools” was not selected in the Xcode settings. After selecting, it worked for me. Open your xcode -> Preferences -> Locations - > Command Line tools

Select xcode version and save

rm -rf  ~/.expo/ios-simulator-app-cache/*

I try it to solve this problem;

Source: https://forums.expo.io/t/error-installing-expo-on-ios-simulator/741

Just ran into this problem, upgrade macOS (high sierra), then run Xcode, it pops up a message box saying there are some necessary modules needed to be installed.

After installation, the simulator works fine.

I ran into this problem after Apple auto-updated my system. Even though I had xCode etc. working previously, the simulator stopped working with React Native because I had not agreed to Apple’s latest terms and conditions. The fix in my case was simply to open xCode and hit “agree”.

Looks like there are quite a few reasons letting the iOS simulator crash … I just solved my specific case and wanted to post what helped me - in case somebody else has the same issue.

My Error message was ( after running $ npm run ios)

Starting packager...
Starting simulator...
Failed to start simulator:

Error: Process exited with non-zero code: 2

I solved the error by installing an older IOS (simulator) version < iOS 11 after I found a post on the EXPO forums (from 2017) - stating that iOS 11 is not supported. https://forums.expo.io/t/cant-install-expo-on-ios-simulator/2299

So I went back to xCode / preferences / Components tab and downloaded latest iOS 10 simulator version - which was 10.3.1 in my case. Then choose that version at the Simulator app: Hardware / device / iOS 10.3 / phone version of your choice.

Hope that information is helpfull for somebody else.

Fixed it by updating Command Line Tools (macOS Sierra version 10.12) for Xcode to version 8.3, which Apple just released.