React Native Reload和Dev Tools不起作用

Dav*_*vid 5 ios reactjs react-native

TL; DR - 我的React Native项目成功运行/渲染.设备震动能力的重装或开发工具无法正常工作.


我按照本指南在现有项目中设置了React Native .我能够使用以下内容成功呈现我的React Native视图:

  1. 在项目根目录中: (JS_DIR=pwd/js; cd node_modules/react-native; npm run start -- --root $JS_DIR)
  2. 在Xcode中构建并运行项目

但是,一旦模拟器运行,我就无法使用command+ r来重新加载JavaScript,也无法使用command+ control+ z来显示开发人员工具.

我没有react-native init <ProjectName>用来创建项目.我正在将React Native添加到现有的Swift项目中.我没有使用,react-native run-ios因为它抛出以下错误:

** 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)
Run Code Online (Sandbox Code Playgroud)

我应该寻求什么来重新加载和开发人员工具能力?

Jef*_*wen 4

如果您有自定义配置并且正在使用 Cocoapods,请确保Podfile指定这些配置应该是debug配置。默认情况下,它们被假定为release配置。将以下行添加到顶部Podfile(假设您的自定义配置是“Dev”、“Local”和“Staging”):

对于 1.0 之前的 Cocoapods 使用xcodeproj

xcodeproj 'MyProject', 'Dev' => :debug, 'Local' => :debug, 'Staging' => :debug
Run Code Online (Sandbox Code Playgroud)

对于 Cocoapods 1.0+ 使用project

project 'MyProject', 'Dev' => :debug, 'Local' => :debug, 'Staging' => :debug
Run Code Online (Sandbox Code Playgroud)

然后,要Pods.xcodeproj更新文件:

rm -rf Pods/
pod install
Run Code Online (Sandbox Code Playgroud)

这将确保DEBUG=1为项目的这些配置设置预处理器宏Pods