ios - react-native run-ios 在连接到 iOS 模拟器时遇到问题

标签 ios react-native ios-simulator

我在 iOS 模拟器上运行我的 react-native 应用程序时遇到问题。它在我的 Windows 机器上的 Android 模拟器上运行良好,所以我很确定它与我自己的代码无关。

这个问题似乎与权限有关。

如果我以我的用户(不是 root)身份运行 react-native run-ios 和模拟器,它似乎发现模拟器很好,但我在构建过程中遇到错误:

 2017-03-12 14:22:05.656 xcodebuild[2612:76143] couldn't read dependency graph from '/Users/jordan/src/anxiety-work-tracker/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/yoga.build/dgph': Permission denied
    
 2017-03-12 14:22:05.677 xcodebuild[2612:76144] couldn't read dependency graph from '/Users/jordan/src/anxiety-work-tracker/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/jschelpers.build/dgph': Permission denied
    
 2017-03-12 14:22:05.677 xcodebuild[2612:76143] unable to create temporary file at /Users/jordan/src/anxiety-work-tracker/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/yoga.build/dgph-1BUDub2D: Permission denied
    
 2017-03-12 14:22:05.677 xcodebuild[2612:76144] unable to create temporary file at /Users/jordan/src/anxiety-work-tracker/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/jschelpers.build/dgph-pZNRO08O: Permission denied
    
 2017-03-12 14:22:05.679 xcodebuild[2612:76144]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-11758/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/BuildSystem/DependencyGraph/XCDependencyGraph.mm:688
 Details:  unable to write dependency graph: Permission denied
 Object:   <XCDependencyGraph>
 Method:   +loadOrCreateInBuildDirectory:withTargetBuildContext:withBasePath:
 Thread:   <NSThread: 0x7facda2f3090>{number = 9, name = (null)}
 Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
 2017-03-12 14:22:05.679 xcodebuild[2612:76143]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-11758/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/BuildSystem/DependencyGraph/XCDependencyGraph.mm:688
 Details:  unable to write dependency graph: Permission denied
 Object:   <XCDependencyGraph>
 Method:   +loadOrCreateInBuildDirectory:withTargetBuildContext:withBasePath:
 Thread:   <NSThread: 0x7facd9f73a90>{number = 8, name = (null)}
   Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
    
 Build Preparation
    
 Couldn't create workspace arena folder '/Users/jordan/src/anxiety-work-tracker/ios/build': Unable to write to info file '<DVTFilePath:0x7facd9e06ec0:'/Users/jordan/src/anxiety-work-tracker/ios/build/info.plist'>'.
    
 Couldn't update module cache session file '/Users/jordan/src/anxiety-work-tracker/ios/build/ModuleCache/Session.modulevalidation': You don’t have permission to save the file “Session.modulevalidation” in the folder “ModuleCache”.
    
    
    
 ** BUILD FAILED **

然后模拟器确实加载了应用程序,但有一个错误提示它无法从模块缓存中加载。

如果我以 root 身份运行 react-native run-ios 并以我的用户身份运行 Simluator,它会说找不到正在运行的模拟设备。

如果我以 root 身份运行两者,则在运行 react-native run-ios 时会得到以下信息:

** BUILD SUCCEEDED **


Installing build/Build/Products/Debug-iphonesimulator/AnxietyWorkTracker.app
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=163):
Unable to lookup service com.apple.CoreSimulator.host_support: 0x44e
Launching org.reactjs.native.example.AnxietyWorkTracker
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=163):
Unable to lookup service com.apple.CoreSimulator.host_support: 0x44e

模拟器不加载任何东西。

更新

根据 Rob 的评论,我更改了目录的权限/所有者。

sudo chown -R <username> <srcPath>

这允许构建以我的非根用户身份成功运行。运行 react-native run-ios 但是构建,打开模拟器,在模拟器中打开应用程序,然后产生此错误:

react-native run-ios error

最佳答案

我知道我在 OP 的更新中添加了这个,但我希望这个 SO 问题被标记为已回答,因为它已经被回答了。

根据 Rob 的评论,问题是对我的源目录的权限。

sudo chown -R <username> ~/src/<project-dir-name>

关于ios - react-native run-ios 在连接到 iOS 模拟器时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42753606/

相关文章:

ios - 图像不显示在设备中,而是显示在模拟器中

ios - 如何将内容大小优先级应用于自调整 UITableViewCell 中的两个 View

ios - 调试 API 请求

ios - swift : Logo on navigation bar along with back button

javascript - 创建接收包含属性 "props"的 "message"的 React 组件

javascript - React-native pubnub WebRTC 视频聊天

listview - React Native ListView : Prepend Items

ios - 录制 iOS 模拟器产生空文件

xcode - MKMapView 不会在 iOS6 的 iPad REAL DEVICE 上缩放和动画

xcode6 - 无法以当前状态: Creating引导设备