API.Swift 文件未在 Apollo GraphQl Swift 中生成
Posted
技术标签:
【中文标题】API.Swift 文件未在 Apollo GraphQl Swift 中生成【英文标题】:API.Swift File is Not genrated in Apollo GraphQl Swift 【发布时间】:2021-08-18 04:50:41 【问题描述】:我正在使用这个 SDK https://github.com/apollographql/apollo-ios
我无法在我的项目中生成 API.Swift 文件
我的 schema.json 文件是正确的格式。
我正在使用此代码运行 Generate API.Swift File
# 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
【问题讨论】:
【参考方案1】:你不能安装 HomeBrew 和 apollo-cli LOL ???
打开终端
安装 HomeBrew ->
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
然后 冲泡安装阿波罗 CLI 打开终端->
brew install apollo-cli
如果您不明白,请遵循本教程 https://www.youtube.com/watch?v=YoKlTbYdFPs&t=301s
这是工作的 Storyboard 和 SwiftUI
【讨论】:
以上是关于API.Swift 文件未在 Apollo GraphQl Swift 中生成的主要内容,如果未能解决你的问题,请参考以下文章
Apollo 网络(错误请求)错误未在 apollo-link-error 中捕获