swift GraphQL脚本无法运行

kgsdhlau  于 2023-03-07  发布在  Swift
关注(0)|答案(1)|浏览(145)

我是grapql新手。我尝试使用脚本生成代码。我已将脚本添加到构建阶段,但显示以下错误的任何原因..我已手动添加插件,如下所示.. x1c 0d1x

/用户/测试/库/开发人员/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

这是我添加文件时的屏幕截图。

quhf5bfb

quhf5bfb1#

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

相关问题