1

I have just started to learn ReactNative because I want to build mobile apps. For that purpose I use my Mac with installed yarn, create-react-native-app and Xcode.

When I run the command:

sudo yarn run ios

the build is successful. No error displayed and the simulator opens but the screen does not display the icon of the app (my project).

enter image description here

If I run the android simulator with Android Studio and the command:

sudo yarn run android

the Android simulator runs and displayed the app.

What might be the issue with the iOS simulator? Please help!

=============

MORE DETAILS:

Here are the commands I use to set up the project:

brew install yarn --without-node
mkdir projectX
cd projectX
sudo yarn global add create-react-native-app
sudo create-react-native .

NodeJS, JDK, JSK are initially installed. After entering these commands I had to upgrade the versions of react and react-native with:

sudo yarn remove react-native
sudo yarn add react-native
sudo yarn remove react
sudo yarn add react

After that:

sudo yarn run eject
adb
sudo yarn run ios
tk421
  • 5,775
  • 6
  • 23
  • 34
Pavel Tashev
  • 311
  • 1
  • 4
  • 12

2 Answers2

3

As mentioned here in the Github issues: https://github.com/react-community/create-react-native-app/issues/422, you most likely used sudo while running the app on the iOS simulator. This operation made root the owner of some files.

Before running the iOS app, try the following command:

sudo chown -R yourUserName ~/react_native_projects, note that react_native_projects should be the folder of your project.

Which should fix the ownership of your project files, and fix the emulator issue. Also take a look at the Github issue page for more helpful commands.

gi097
  • 7,313
  • 3
  • 27
  • 49
  • I did the following: `sudo chown -R admin ~/Documents/SoftwareDevelopment/_Education/ReactNative/projectX/` `sudo yarn run ios` The simulator and the metro bundler opened. The simulator does not show the app icon but also the Metro Bundler is stuck to this message "Loading dependency graph, done." and it does not continue...which wasn't the case before that. – Pavel Tashev Dec 07 '18 at 19:36
  • Ok, it worked now! Thank you for the help. Here is what I did step by step: `sudo chown -R myUserName ~/react_native_project` then I restarted the Mac (following the comments from the GitHub link) and in the terminal I typed `yarn run ios`. Notice that I didn't use `sudo`! If you try to run it with `sudo` it won't work. Thanks mate! ;) – Pavel Tashev Dec 08 '18 at 19:06
1

Thanks to Giovanni Terlingen I fixed it. Here are the steps I followed:

First I changed the ownership of the directory which contains my project to the user to be owned by my user.

sudo chown -R myUserName ~/react_native_project

Then I restarted my Mac (following the comments from the GitHub link provided by Giovanni) and in the terminal I typed:

yarn run ios

Notice that I didn't use sudo! If you try to run it with sudo it won't work.

Pavel Tashev
  • 311
  • 1
  • 4
  • 12