我正在使用我使用Carthage安装的GraphQL的apollo框架,但是当我在构建阶段运行脚本生成API.swift文件时出现错误。
错误是
> [myproject]/Carthage/Build/iOS/Apollo.framework: is a directory
Command /bin/sh failed with exit code 126
我确实添加了apollo doc中的脚本:
这是脚本本身:
APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"
if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
exit 1
fi
cd "${SRCROOT}/${TARGET_NAME}"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift
当然,我还预先生成了schema.json
答案 0 :(得分:1)
回答可能有点晚,但是至少在我的机器上APOLLO_FRAMEWORK_PATH
被评估为两个框架(iOS和watchOS),因此使用$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh
运行捆绑脚本失败。
假设脚本没有什么不同(从apollo-ios@0.8.0
版本开始,它们没有变化),您可以在find命令的末尾添加-print -quit
,使其仅返回一个结果。
完整脚本为:
APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1 -print -quit)"
if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
exit 1
fi
cd "${SRCROOT}/${TARGET_NAME}"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift