【问题标题】:Unable to build Xcode iOS project using Apollo framwork to work with GraphQL无法使用 Apollo 框架构建 Xcode iOS 项目以使用 GraphQL
【发布时间】:2019-01-08 04:00:53
【问题描述】:

我正在开发一个连接到 GraphQL API 的 Xcode 项目。为此,我使用了Apollo framework

在我的项目中,我已经安装了包含 Apollo 框架的 cocoapod,然后在 Xcode 中添加了以下运行脚本:

if which apollo-codegen >/dev/null; then

  APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"

  if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
    echo "warning: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
    exit 0
  fi

  cd "${SRCROOT}/${TARGET_NAME}/GraphQL"
  $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate \
    $(find . -name '*.graphql') \
    --schema schema.json \
    --output Generated/GraphQLAPI.swift
else
  echo "Skipping Apollo code generation"
fi

这是它在 Xcode 中的样子:

我在 Xcode 中的目录结构是这样的:

然后我从终端运行以下命令:

npm install -g apollo-codegen

当我尝试构建我的 Xcode 项目时,很遗憾地收到以下构建错误:

/Users/JohnDoe/Library/Developer/Xcode/DerivedData/The_Game-dfpiqreyqdjocaawjrfwhrxhdosf/Build/Intermediates.noindex/The Game.build/Debug-iphonesimulator/The Game.build/Script-7851AAFF2110C71000903FAD.sh:第 12 行:/Users/JohnDoe/Library/Developer/Xcode/DerivedData/The_Game-dfpiqreyqdjocaawjrfwhrxhdosf/Build/Products/Debug-iphonesimulator/Apollo/Apollo.framework/check-and-run-apollo-codegen.sh:没有这样的文件或目录

老实说,我不知道为什么我会得到这个区域。有谁知道为什么?

【问题讨论】:

    标签: ios xcode graphql apollo


    【解决方案1】:

    最近版本的 apollo ios 中的构建脚本发生了变化,因为 apollo-codegen 现在是新 apollo cli 的一部分。它应该引用check-and-run-apollo-cli.sh

    此外,通过在 podfile 中指定版本,确保使用最新版本的 apollo(当前为 0.9.2)。您可能还需要通过运行 pod repo update 来更新您的 pod 存储库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      • 2015-08-18
      • 2020-02-23
      • 1970-01-01
      • 1970-01-01
      • 2017-01-10
      相关资源
      最近更新 更多