【发布时间】:2017-08-02 21:03:18
【问题描述】:
我在 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>
这允许构建以我的非 root 用户身份成功运行。运行 react-native run-ios 然而构建,打开模拟器,在模拟器中打开应用程序,然后产生这个错误:
【问题讨论】:
-
我所有的 React Native 项目文件都归
my user和staff所有,而你却得到了权限被拒绝的错误。尝试更改项目的文件所有权 (chown -R jordan:staff Users/jordan/src/anxiety-work-tracker) 并重新运行react-native run-ios。 -
添加权限可以让我运行
react-native run-ios。然而,现在模拟器在加载应用程序后显示错误Native module cannot be null.。 Iirc,这与我作为我的用户在更改所有者之前运行时遇到的错误相同 - 主要区别在于在chown之前,构建本身失败了。我不确定这个问题是否应该是一个新的 SO 问题。 -
你能发布新的错误吗?创建新组件时是否包括 React 和 React Native?
-
@Rob 我更新了 OP。
-
是的,我在每个组件文件中都包含 React 和 React Native。
标签: ios react-native ios-simulator