react-native run-ios在连接iOS模拟器时出现问题

时间:2017-03-12 21:48:11

标签: ios react-native ios-simulator

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

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

如果我运行react-native run-ios并将模拟器作为我的用户(不是root用户),它似乎找到了模拟器,但我在构建过程中遇到错误:

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>

这使得构建成功地以非root用户身份运行。无论如何运行react-native run-ios,打开模拟器,在模拟器中打开应用程序,然后产生此错误:

react-native run-ios error

1 个答案:

答案 0 :(得分:3)

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

Per Rob的评论,问题是我的源目录的权限。

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