Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Reload and Dev Tools Do Not Work

TL;DR – My React Native project runs/renders successfully. The reload or developer tools on device shake abilities are not working.


I've setup React Native within an existing project following this guide. I am able to successfully render my React Native views with the following:

  1. In project root: (JS_DIR=pwd/js; cd node_modules/react-native; npm run start -- --root $JS_DIR)
  2. Build and run the project within Xcode

However, once the simulator is running I cannot use command+r to reload the JavaScript, nor am I able to use command+control+z to display the developer tools.

I did not use react-native init <ProjectName> to create the project. I am adding React Native to an existing Swift project. I am not using react-native run-ios as it throws the following errors:

** BUILD FAILED **


The following build commands failed:
    CompileC /Users/username/Sites/iOS/project-name/build/Build/Intermediates/Pods.build/Local-iphonesimulator/FXBlurView.build/Objects-normal/x86_64/FXBlurView.o FXBlurView/FXBlurView/FXBlurView.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC /Users/username/Sites/iOS/project-name/build/Build/Intermediates/Pods.build/Local-iphonesimulator/FXBlurView.build/Objects-normal/i386/FXBlurView.o FXBlurView/FXBlurView/FXBlurView.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC /Users/username/Sites/iOS/project-name/build/Build/Intermediates/Pods.build/Local-iphonesimulator/FXBlurView.build/Objects-normal/x86_64/FXBlurView-dummy.o Target\ Support\ Files/FXBlurView/FXBlurView-dummy.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC /Users/username/Sites/iOS/project-name/build/Build/Intermediates/Pods.build/Local-iphonesimulator/FXBlurView.build/Objects-normal/i386/FXBlurView-dummy.o Target\ Support\ Files/FXBlurView/FXBlurView-dummy.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(4 failures)
Installing build/Build/Products/Debug-iphonesimulator/ProjectName.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/username/Sites/iOS/project-name/node_modules/promise/lib/done.js:10
      throw err;
      ^

Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/ProjectName.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:91:34)
    at runIOS.js:24:5
    at tryCallTwo (/Users/username/Sites/iOS/project-name/node_modules/promise/lib/core.js:45:5)
    at doResolve (/Users/username/Sites/iOS/project-name/node_modules/promise/lib/core.js:200:13)
    at new Promise (/Users/username/Sites/iOS/project-name/node_modules/promise/lib/core.js:66:3)
    at Array.runIOS (runIOS.js:23:10)
    at Object.run (/Users/username/Sites/iOS/project-name/node_modules/react-native/local-cli/cli.js:86:13)
    at Object.<anonymous> (/Users/username/.nvm/versions/node/v4.2.4/lib/node_modules/react-native-cli/index.js:88:7)

What should I look for to get the reload and developer tools abilities working?

like image 249
David Avatar asked May 04 '16 14:05

David


People also ask

How do I use quick refresh in React Native?

Fast Refresh is a React Native feature that allows you to get near-instant feedback for changes in your React components. Fast Refresh is enabled by default, and you can toggle "Enable Fast Refresh" in the React Native developer menu. With Fast Refresh enabled, most edits should be visible within a second or two.


1 Answers

If you have custom configurations and you're using Cocoapods, make sure the Podfile specifies that those configurations should be debug configurations. By default they are assumed to be release configurations. Add the following line to the top of your Podfile (assuming your custom configs are "Dev", "Local", and "Staging"):

For pre-1.0 Cocoapods use xcodeproj:

xcodeproj 'MyProject', 'Dev' => :debug, 'Local' => :debug, 'Staging' => :debug

For Cocoapods 1.0+ use project:

project 'MyProject', 'Dev' => :debug, 'Local' => :debug, 'Staging' => :debug

Then, to get the Pods.xcodeproj file to update:

rm -rf Pods/
pod install

This will ensure the DEBUG=1 Preprocessor Macro is set for those configurations for the Pods project.

like image 114
Jeff Bowen Avatar answered Sep 21 '22 22:09

Jeff Bowen