iOS - Add Code Generation Build Step using Swift Scripting Library

Hi guys, I’m following the steps on Installation - Client (iOS) - Apollo GraphQL Docs which provides 3 script options:

  • Swift Package Manager Run Script
  • CocoaPods Run Script
  • Carthage Run Script

I opted to use the first one but when executing, it warns me that it will be deprecated soon and that I should use the Swift Scripting method instead (Swift scripting - Client (iOS) - Apollo GraphQL Docs).

I was able to configure the template project and download the schema by running swift run ApolloCodegen downloadSchema on the terminal. However, I’m unclear what should I put on the actual Xcode build step. Can you please provide guidance or point me to the correct documentation? Thank you!

So glad you’re trying out the new scripting!

Just a little further down the page was the answer you’re looking for! Swift scripting - Client (iOS) - Apollo GraphQL Docs

cd "${SRCROOT}"/ApolloCodegen
xcrun -sdk macosx swift run ApolloCodegen generate
1 Like

Thank you Anthony! It was right there in front of me :rofl: but I stopped reading on Adding a .graphql file with an operation because I thought I wasn’t done with the first step. Thanks a lot anyways.