React Native 构建命令失败:PhaseScriptExecution ...(域=NSPOSIXErrorDomain,代码=2)

React Native Build Commands Failed: PhaseScriptExecution ... (domain=NSPOSIXErrorDomain, code=2)

环境

Mac OS X Version 10.11.3 (15D21)
Xcode Version 7.2 (7C68)
Simulator Version 9.2 (SimulatorApp-643)
react-native-cli 0.1.10
node v5.5.0

我在运行安装应用程序之前做了什么

npm install -g react-native-cli
react-native init DemoProjectDELETEME
cd ./DemoProjectDELETEME
react-native run-ios

我是 React Native 的新手。当我尝试 运行 iOS 模拟器上的默认应用程序时,出现以下错误。我发现了一个类似的问题,但它并没有解决我的问题。

Xcode6 can't run any app in simulator ( Domain = NSPOSIXErrorDomain, Code = 3 )

重启机器和模拟器后问题依然存在。

** BUILD FAILED **


The following build commands failed:
    PhaseScriptExecution Run\ Script /Users/x/Desktop/DemoProjectDELETEME/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Script-006B79A01A781F38006873D1.sh
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/DemoProjectDELETEME.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/x/Desktop/DemoProjectDELETEME/node_modules/promise/lib/done.js:10
      throw err;
      ^

Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/DemoProjectDELETEME.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:77:34)
    at runIOS.js:24:5
    at tryCallTwo (/Users/x/Desktop/DemoProjectDELETEME/node_modules/promise/lib/core.js:45:5)
    at doResolve (/Users/x/Desktop/DemoProjectDELETEME/node_modules/promise/lib/core.js:200:13)
    at new Promise (/Users/x/Desktop/DemoProjectDELETEME/node_modules/promise/lib/core.js:66:3)
    at Array.runIOS (runIOS.js:23:10)
    at Object.run (/Users/x/Desktop/DemoProjectDELETEME/node_modules/react-native/local-cli/cli.js:86:13)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:73:7)

当我尝试从 Xcode 启动应用程序时出现跟随者错误。

项目根目录中的

sudo npm start 解决了问题,但 react-native run-ios 仍然 BUILD FAILED.

感谢您花时间查看我的问题。

在所有命令前加上sudo即可解决问题

sudo react-native init ProjectName

sudo chmod 777 ProjectName

cd ProjectName
sudo react-native run-ios 
  1. 在 Xcode
  2. 中打开你的 react-native 项目
  3. 使用项目名称创建一个新架构。
  4. 问题就解决了

尝试运行react-native upgrade

参见 Github 话题:https://github.com/facebook/react-native/issues/7308#issuecomment-219597774

我正在使用端口 8081 :

lsof -n -i4TCP:8081

对我来说,我只需要编辑 iOS 项目构建设置

未设置产品捆绑包标识符

您需要为项目和 2 个目标设置它

问题出在构建和运行您的应用程序的 js 文件中。除非你的项目、方案和产品名称都相同,否则你会出错,尤其是在模拟器上。

好消息是我提交了a pull request that fixes the problem.请给它投票,这样我们就不用担心重命名时会破坏东西了。

打开您的 Xcode 项目

运行这

你应该有 2 个来自 RCTSRWebSocket.m

的错误

将 (void) 添加到两行的开头:

SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);

变成

(void)SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);

使用 Xcode 或终端保存并重新 运行 您的项目。它应该肯定有效。我之前测试过所有的解决方案,这个是唯一为我工作的人。

令人惊讶的是,这就是我的解决方案:在 Xcode 中打开文件 Views/RTCScrollView.m 并将变量 _refreshControl 更改为 刷新控件。所有出现的 _refreshControl 都已标记为错误。新代码变为:

- (void)setRefreshControl:(RCTRefreshControl *)refreshControl
{
  if (refreshControl) {
    [refreshControl removeFromSuperview];
  }
  refreshControl = refreshControl;
  [self addSubview:refreshControl];
}

1.Go 到文件 -> 项目设置 2.Click 高级按钮 3.Select "Custom" 和 select "Relative to Workspace" 在下拉 4.Change "Build/Products" 至 "build/Build/Products" 5.click完成,完成

对我来说,我需要将 XCode 的版本从 Yosemite 升级到 Sierra。

这可以通过 App Store > Updates.

完成

我的问题已经解决了,有同样情况的可以试试

我遇到了同样的错误:

Print: Entry, ":CFBundleIdentifier", Does Not Exist

当我从 learning react native 克隆现有的 react-native 项目时。

  1. 我在不同的目录下初始化(使用{react-native init yourProjectName})一个同名的新项目

  2. 将每个有用的 *.ios.js 文件从我在别处克隆的文件复制到这个新项目。

这对我有用。

编辑文件,ProjectName/node_modules/react-native/local-cli/runIOS/runIOS.js 第 18 行:将整行代码替换为以下内容:

return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;

第 146 行:取消注释 '-derivedDataPath', 'build',

之后 运行 来自终端的命令:sudo react-native 运行-ios

对我来说,我的问题是 Mcafee 在端口 8081 上 运行ning,所以我 运行 应用程序在另一个端口上遵循这个答案 基本上:

react-native 运行-ios --port 1234 反应本机启动 --port 1234

我正在使用 React native 0.55+

对我有用的是 ios 目录中的 运行 pod install

运行

npx pod-install

帮我解决了问题。

尝试运行 npx pod-install 还要检查权限。也许你应该 运行 react-native run-iossudo?