我正在使用我使用 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
最佳答案
回答可能有点晚,但至少在我的机器上 APOLLO_FRAMEWORK_PATH
被评估为两个框架(iOS 和 watchOS),因此使用 $APOLLO_FRAMEWORK_PATH/check-and 运行捆绑脚本-run-apollo-codegen.sh
失败。
假设脚本没有区别(从 apollo-ios@0.8.0
版本开始他们没有)你可以添加 -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
关于swift - 运行脚本阶段错误 : framework is a directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47692735/