ios GraphQL脚本无法运行

ukxgm1gy  于 2023-03-09  发布在  iOS
关注(0)|答案(1)|浏览(205)

我是graphQL新手。我尝试使用脚本生成代码。我已将脚本添加到构建阶段,但由于某种原因,我看到以下错误。我已手动添加插件,如下所示:

/用户/测试/库/开发人员/Xcode/派生数据/QL-ffdpoxkzuezgcvehdtxkwmpnuxjl/构建/中间体.noindex/QL.构建/调试-iPhone模拟器/QL.构建/脚本-52B35D7229B6257F006710FD.sh:第23行:/用户/测试/库/开发人员/Xcode/派生数据/QL-ffdpoxkzuezgcvehdtxkwmpnuxjl/源包/ checkout /apollo-ios/scripts/run-bundled-codegen.sh:没有这样的文件或目录命令阶段脚本执行失败,退出代码为非零

项目结构:


脚本如下:

# Go to the build root and search up the chain to find the Derived Data Path where the source packages are checked out.
DERIVED_DATA_CANDIDATE="${BUILD_ROOT}"

while ! [ -d "${DERIVED_DATA_CANDIDATE}/SourcePackages" ]; do
  if [ "${DERIVED_DATA_CANDIDATE}" = / ]; then
    echo >&2 "error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'"
    exit 1
  fi

  DERIVED_DATA_CANDIDATE="$(dirname "${DERIVED_DATA_CANDIDATE}")"
done

# Grab a reference to the directory where scripts are checked out
SCRIPT_PATH="${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/apollo-ios/scripts"

if [ -z "${SCRIPT_PATH}" ]; then
    echo >&2 "error: Couldn't find the CLI script in your checked out SPM packages; make sure to add the framework to your project."
    exit 1
fi

cd "${SRCROOT}/${TARGET_NAME}"
"${SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile="schema.json" API.swift

下面是我添加文件时的屏幕截图:

z0qdvdin

z0qdvdin1#

根据Apollo文档,假设.graphql文件和schema.json的相对路径与项目结构中的脚本所示的路径相同,也许您应该将运行脚本在目标依赖项和编译资源之间移动以执行

相关问题