swift - 运行脚本阶段错误 : framework is a directory

标签 swift xcode apollo carthage

我正在使用我使用 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/

相关文章:

ios - 如何使用模型类初始化 Core Data ManagedObjectContext?

swift - 按两个属性对对象数组进行排序

ios - 通过 “perform segue”传递错误返回nil?

apollo - 如何执行异步提取请求,然后重试上一个失败的请求?

graphql - GraphQL : Create requests with multiple optional arguments

ios - UITableViewCell 错误的内容宽度

swift - 如何执行推送 UIViewController 或呈现 UIAlertController?

ios - 在 iTunes Connect 中推送待开发者发布的应用更新

xcode - Xcode是否具有代码导航功能?

javascript - 使用 apollo 改变数组