如何将 `pod install` 步骤添加到 ios 构建过程

How to add `pod install` step to ios build process

我刚刚在我的 react-native 项目中安装了一个依赖项,需要手动配置 ios/Podfile

如果我有这个项目的存储库的新克隆,react-native run-ios 将无法工作,直到我 运行 pod install 在 ios 文件夹的上下文中.我想让它作为 ios 构建的一部分自动发生,而不是作为一个单独的步骤。

我试过在 xcode 中添加 pod install 作为 "Run Script" 并将其移至构建顺序的顶部,但没有成功。

如何向 ios 构建过程添加 pod install 步骤?

我认为在你的包脚本中指定一个单独的脚本更容易:

{
  "name": "Awesome Project",
  "version": "1.8.0",
  "scripts": {
    "start-ios": "cd ./ios && pod install && cd .. && react-native run-ios",
  },
  ...some other stuff here...
}

P.S。每当您想构建应用程序时安装 pods 似乎并不明智。它需要许多冗余步骤,并且您想考虑只在您的存储库中包含 pods 源,恕我直言,这是更好的方法。 (如果在克隆回购后安装一次 pods 不是一个选项)