TL;DR – 我的 React Native 项目成功运行/呈现。设备抖动功能的重新加载或开发者工具不起作用。
我在 this guide 之后的现有项目中设置了 React Native .我能够使用以下内容成功呈现我的 React Native View :
- 在项目根目录中:
(JS_DIR=pwd/js; cd node_modules/react-native; npm run start -- --root $JS_DIR)
- 在 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)
我应该寻找什么才能使重新加载和开发人员工具功能发挥作用?
最佳答案
如果您有自定义配置并且您正在使用 Cocoapods,请确保 Podfile
指定这些配置应该是 debug
配置。默认情况下,它们被假定为 release
配置。将以下行添加到 Podfile
的顶部(假设您的自定义配置是“Dev”、“Local”和“Staging”):
对于 1.0 之前的 Cocoapods 使用 xcodeproj
:
xcodeproj 'MyProject', 'Dev' => :debug, 'Local' => :debug, 'Staging' => :debug
对于 Cocoapods 1.0+ 使用 project
:
project 'MyProject', 'Dev' => :debug, 'Local' => :debug, 'Staging' => :debug
然后,获取要更新的 Pods.xcodeproj
文件:
rm -rf Pods/
pod install
这将确保为 Pods
项目的那些配置设置 DEBUG=1
预处理器宏。
关于ios - React Native 重新加载和开发工具不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37031192/