How to use code gen tool in XCode project without a Package.Swift file

Following “Getting Started documentation” in Getting Started with Apollo iOS - Apollo GraphQL Docs and using SPM with XCode project (no package.swift file for the XCode project). I am using the latest version 1.0.3. The docs for older version 0.53.0 uses a build phase script which is no longer applicable to the new version 1.0.3.

The steps listed under Step 5: Setup and run code generation → for Swift Package Manager option does not help me, because it is referring to Package.swift file. Are there specific steps to use the code gen tool if using SPM with XCode project ?

There is a section of the CLI docs that has detail on using the SwiftPM plugin via Xcode. We are going to be removing the SwiftPM plugin though, see #2565. The experience is not good enough for us to continue supporting it. Once it improves in Xcode and the sandbox behaviour is easier to work with we can bring the plugins back.

Thank you. I did try that before and again just now. How do I know the code generation worked? I am seeing the alert to allow file changes and I approve. There are no errors and build succeeds but I am not seeing the auto-generated API.swift file. Where should I look for the code gen file?

As @calvincestari said, we’re going to be removing the SwiftPM plugin. I recommend you just move over to using the Codegen CLI from the command line using the “Manual Installation” method in the docs now.

We’re looking into how to package and distribute the CLI so you don’t have to compile it locally soon as well.

How do I know the code generation worked?

Xcode plugins don’t do a great job of surfacing errors and successful runs to the user. One of the many reasons we are going to drop them. If you run the CLI from the command line, you’ll get output indicating if it was successful or not.

There are no errors and build succeeds but I am not seeing the auto-generated API.swift file. Where should I look for the code gen file?

We don’t generate a single API.swift file anymore, as for most projects, that file got so large that Xcode would start to hang just trying to open it.

Your generated models will be output as group of files as configured in your codegen config output options.