在 swift 包管理器中添加 Apollo 的代码生成构建脚本时出错
Error when adding a code generation build script of Apollo in swift package manager
xcode给我的错误是:
./../SourcePackages/checkouts/apollo-ios/scripts: No such file or directory
我在the official website上的官方脚本里看到了这行代码,我有xcode11,我用的是Apollo iOS 0.16。 0 与 Swift 包管理器
几周前我遇到了同样的问题。事实上,这是 Apollo iOS 网站文档的一个错误。我意识到在发布配置中构建时,脚本没有在正确的文件夹中找到脚本。但是,在调试配置中构建时,路径工作正常。我指的是这一行 ../../SourcePackages/checkouts/apollo-ios/scripts
所以为了解决这个问题,我们必须像下面这样检测构建配置类型:
# Go to the build root and go back up to where SPM keeps the Apollo iOS repo checked out.
cd "${BUILD_ROOT}"
if [ "${CONFIGURATION}" == "Release" ]; then
cd "../../../../../SourcePackages/checkouts/apollo-ios/scripts"
fi
if [ "${CONFIGURATION}" == "Debug" ]; then
cd "../../SourcePackages/checkouts/apollo-ios/scripts"
fi
APOLLO_SCRIPT_PATH="$(pwd)"
if [ -z "${APOLLO_SCRIPT_PATH}" ]; then
echo "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}"
"${APOLLO_SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile="schema.json" API.swift
xcode给我的错误是:
./../SourcePackages/checkouts/apollo-ios/scripts: No such file or directory
我在the official website上的官方脚本里看到了这行代码,我有xcode11,我用的是Apollo iOS 0.16。 0 与 Swift 包管理器
几周前我遇到了同样的问题。事实上,这是 Apollo iOS 网站文档的一个错误。我意识到在发布配置中构建时,脚本没有在正确的文件夹中找到脚本。但是,在调试配置中构建时,路径工作正常。我指的是这一行 ../../SourcePackages/checkouts/apollo-ios/scripts
所以为了解决这个问题,我们必须像下面这样检测构建配置类型:
# Go to the build root and go back up to where SPM keeps the Apollo iOS repo checked out.
cd "${BUILD_ROOT}"
if [ "${CONFIGURATION}" == "Release" ]; then
cd "../../../../../SourcePackages/checkouts/apollo-ios/scripts"
fi
if [ "${CONFIGURATION}" == "Debug" ]; then
cd "../../SourcePackages/checkouts/apollo-ios/scripts"
fi
APOLLO_SCRIPT_PATH="$(pwd)"
if [ -z "${APOLLO_SCRIPT_PATH}" ]; then
echo "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}"
"${APOLLO_SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile="schema.json" API.swift