28

Environment

Mac OS X Version 10.11.3 (15D21)
Xcode Version 7.2 (7C68)
Simulator Version 9.2 (SimulatorApp-643)
react-native-cli 0.1.10
node v5.5.0

What I did before running the app

npm install -g react-native-cli
react-native init DemoProjectDELETEME
cd ./DemoProjectDELETEME
react-native run-ios

I am new to React Native. When I try to run the default app on iOS simulator I got the following errors. I found a similar issue but it does not solve my problem.

Xcode6 can't run any app in simulator ( Domain = NSPOSIXErrorDomain, Code = 3 )

After restart the machine and simulator the issues still persistent.

** BUILD FAILED **


The following build commands failed:
    PhaseScriptExecution Run\ Script /Users/x/Desktop/DemoProjectDELETEME/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Script-006B79A01A781F38006873D1.sh
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/DemoProjectDELETEME.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
/Users/x/Desktop/DemoProjectDELETEME/node_modules/promise/lib/done.js:10
      throw err;
      ^

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

    at checkExecSyncError (child_process.js:464:13)
    at Object.execFileSync (child_process.js:484:13)
    at _runIOS (runIOS.js:77:34)
    at runIOS.js:24:5
    at tryCallTwo (/Users/x/Desktop/DemoProjectDELETEME/node_modules/promise/lib/core.js:45:5)
    at doResolve (/Users/x/Desktop/DemoProjectDELETEME/node_modules/promise/lib/core.js:200:13)
    at new Promise (/Users/x/Desktop/DemoProjectDELETEME/node_modules/promise/lib/core.js:66:3)
    at Array.runIOS (runIOS.js:23:10)
    at Object.run (/Users/x/Desktop/DemoProjectDELETEME/node_modules/react-native/local-cli/cli.js:86:13)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:73:7)

Got the follower error when I am trying to launch the app from Xcode.

enter image description here

sudo npm start in project root solves the issue, but react-native run-ios still BUILD FAILED.

Thanks for your time viewing my question.

Community
  • 1
  • 1
XY L
  • 25,431
  • 14
  • 84
  • 143
  • 10
    it's always extremely disappointing to come across such issues when following instructions to create the basic sample project. It doesn't inspire much hope in React Native. – Max MacLeod Jun 23 '16 at 15:23

17 Answers17

18

For me port 8081 was in use :

lsof -n -i4TCP:8081

phani
  • 1,134
  • 1
  • 11
  • 24
17

Try running react-native upgrade

See Github thread: https://github.com/facebook/react-native/issues/7308#issuecomment-219597774

Nima Izadi
  • 996
  • 6
  • 18
8

1.Go to File -> Project settings 2.Click the Advanced button 3.Select "Custom" and select "Relative to Workspace" in the pull down 4.Change "Build/Products" to "build/Build/Products" 5.click done, doneenter image description here

Katta Nagarjuna
  • 1,539
  • 2
  • 12
  • 12
  • 1
    thanks this helped. Could this have been duplicated by simply removing something instead? Also, the picture and text steps don't align. The ss also changed the Intermediates field. – Drew Mar 22 '17 at 12:14
5

The problem is in the js file that builds and runs your app. Unless your project, scheme, and Product Name are all the same, you'll get errors, especially on simulators.

The good news is that I submitted a pull request that fixes the problem. Please go upvote it so we don't have worry about things breaking when we rename things.

Steve Potter
  • 1,899
  • 2
  • 22
  • 25
  • 1
    This is the only sensible answer in this thread. You may want to also add that this behavior may persist until watchman and/or the simulator are restarted. Other than that, I cannot believe the answers given to fix this issue. I may want to add my own like "Grab your crotch, turn your head, cough three times, and then spin around", because it will help just as much as a lot of these others based on pure coincidence. – DBrown Mar 18 '17 at 17:17
4

For me I just needed to edit the iOS project build settings

Product Bundle Identifier was not set

You need to set it for both the Project and 2 Targets

enter image description here

damien murphy.
  • 371
  • 2
  • 16
3
  1. Open your react-native project in Xcode
  2. Create a new schema with project name.
  3. the problem will be solved enter image description here
Aathi
  • 2,599
  • 2
  • 19
  • 16
1

Adding sudo in front of all commands solves the problem.

sudo react-native init ProjectName

sudo chmod 777 ProjectName

cd ProjectName
sudo react-native run-ios 
XY L
  • 25,431
  • 14
  • 84
  • 143
  • 1
    Error is gone but now it says "No devices are booted" – leo7r Sep 05 '16 at 02:29
  • 2
    This will definitely cause the need for sudo every time you want to run the project in the future. Sudo should not be needed. @Aathi answer worked for me. – Tieme Sep 06 '16 at 09:51
  • 1
    Horrible answer. You can use chmod 755 (user: full, group/world: read/write) or 744 (full, read). Using 777 is an open invitation to anything and everything. If you need to ever use sudo for your projects, you may want investigate the reason why these tools and libraries are not accessible to you as a regular user. If your tools are not installed in a user-accessible folder, issues will continue to arise; you should not ever have to use 'sudo' for your projects. Instead fix your permissions: https://docs.npmjs.com/getting-started/fixing-npm-permissions – DBrown Mar 18 '17 at 17:27
1

For me, I needed to upgrade my version of XCode from Yosemite to Sierra.

This can be done via App Store > Updates.

Matt D. Webb
  • 3,216
  • 4
  • 29
  • 51
1

What worked for me was running pod install from the ios directory

green1919
  • 289
  • 2
  • 13
1

Running

npx pod-install

solved the problem for me.

1

For my case: If your project folder name called like "Example Project"

You must change it to "Example_Project"

Spaces are causen this error.

omkocer
  • 153
  • 1
  • 9
0

Open Your Xcode project

Run it

You should have 2 errors from RCTSRWebSocket.m

add (void) to the beginning of both line :

SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);

become

(void)SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);

Save and Re-run your project with Xcode or terminal. It should work for sure. I have tested all the solution before, this one is the only who worked for me.

Seb33300
  • 7,464
  • 2
  • 40
  • 57
Ciboulette
  • 145
  • 1
  • 2
  • 9
0

Surprisingly, this was the solution for me: Open the file Views/RTCScrollView.m in Xcode and change the variable _refreshControl to refreshControl. All occurrences of _refreshControl were already marked as errors. The new code becomes:

- (void)setRefreshControl:(RCTRefreshControl *)refreshControl
{
  if (refreshControl) {
    [refreshControl removeFromSuperview];
  }
  refreshControl = refreshControl;
  [self addSubview:refreshControl];
}
Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76
0

I fixed my issue, you can try it if you are in the same condition.

I encountered the same error:

Print: Entry, ":CFBundleIdentifier", Does Not Exist

When I clone an existing react-native project from learning react native.

  1. I initialize (using {react-native init yourProjectName}) a new project with the same name in a different directory

  2. copy every useful *.ios.js file to this new project from the one I clone elsewhere.

This works for me.

Draken
  • 3,134
  • 13
  • 34
  • 54
0

Edit the file ,ProjectName/node_modules/react-native/local-cli/runIOS/runIOS.js Line no 18 : replace the entire line of code with the following :

return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;

Line no: 146: uncomment '-derivedDataPath', 'build',

after that run the command from the terminal: sudo react-native run-ios

Sachin Kumaram
  • 900
  • 1
  • 10
  • 27
0

For me, my problem was that Mcafee is running on port 8081, so I run the app on a different port following this answer https://stackoverflow.com/a/50649969/5323419 Basically:

react-native run-ios --port 1234 react-native start --port 1234

I am using React native 0.55+

Henrique Jensen
  • 399
  • 3
  • 6
0

Try to run npx pod-install Also check the permissions. Maybe you should run react-native run-ios with sudo?

laneboyandrew
  • 290
  • 6
  • 17