Reputation: 198
I am using apollo-ios
library via the Swift Package Manager, and I can install apollo-ios-cli
from the Xcode menu. However, when building my app in a CI/CD environment, the tool cannot interact with this GUI menu, so it has to install the apollo-ios-cli using the command line.
I can do that using the following commands:
dirs=(~/Library/Developer/Xcode/DerivedData/my-app-name-*)
cd "${dirs[1]}"/SourcePackages/checkouts/apollo-ios
swift package plugin --allow-writing-to-package-directory apollo-cli-install
cd $SOURCE_DIR
"${dirs[1]}"/SourcePackages/checkouts/apollo-ios/apollo-ios-cli generate
However, this approach uses a wildcard to search for the build directory, which makes it a bit fragile.
Is there a simpler way?
Upvotes: -1
Views: 247
Reputation: 198
I could not find a solution, so I finally gave up on that approach. Instead, I wrote a shell script that downloads a apollo-ios-cli
and runs code generation. It looks like the following.
# Use the same version of the Apollo library that you are using.
CLI_URL="https://github.com/apollographql/apollo-ios/releases/download/1.3.3/apollo-ios-cli.tar.gz"
curl -L $CLI_URL -o apollo-ios-cli.tar.gz
tar -xzf apollo-ios-cli.tar.gz
chmod +x apollo-ios-cli
./apollo-ios-cli generate
This is not the actual solution, but it can be a workaround.
Upvotes: 0