Apollo 1.0.5 - Library and CLI version mismatch

I updated Apollo to version 1.0.5 using SPM, installed the CLI via Xcode plugin and after running apollo-ios-cli generate i get the following:

We’ve detected that the version of the Apollo Codegen CLI does not match the version of the Apollo library used in your project. This may lead to incompatible generated objects.
Please update your version of the Codegen CLI by following the instructions at:
The Codegen CLI - Apollo GraphQL Docs

CLI version: 1.0.5
Apollo version: 1.0.3

To ignore this error during code generation, use the argument: --ignore-version-mismatch.

I’m a bit confused since i can clearly see that Apollo is at version 1.0.5, but the generate cli command thinks it is 1.0.3. I tried clearing derived data, build folder, reseting package caches and reinstalling apollo all together, nothing works so far.

I appreciate any help

Hi @hydro1337x - this is the first bug report we’ve had for the version mismatch so thank you for reporting it.

I’m a bit confused since i can clearly see that Apollo is at version 1.0.5

Do you mean that in Xcode the Apollo package dependency shows as 1.0.5?
Screen Shot 2022-12-23 at 10.56.09 AM

I tried clearing derived data, build folder, reseting package caches and reinstalling apollo all together, nothing works so far.

That’s pretty weird, I would have expected one of these actions to clear out any stale versions.

Here is the guts of the function that does the version checking.

  • The first thing it does it look for a Package.resolved file in the project root. I know you said you were managing it through Xcode so you shouldn’t have that file.
  • After that it’ll look for Package.resolved in <projectFileName>/project.xcworkspace/xcshareddata/swiftpm/ to resolve the version being used.

Take a look at either of those paths and see what turns up. The fact that it’s telling you there is a version mismatch means it’s finding one of them because in the case of it being missing it assumes there is no version yet and shouldn’t be returning that error.

Hey @calvincestari , thanks for the fast reply!

Do you mean that in Xcode the Apollo package dependency shows as 1.0.5?

Exactly

My git diff tells me that Package.resolved indeed has updated

I’ve just tried to replicate this but cannot reproduce the error.

These are the steps I took:

  • Create a new Xcode project
  • Add apollo-ios dependency specifically targeting 1.0.3
  • Used the Xcode plug-in to generate the codegen configuration file
  • Updated apollo-ios dependency to 1.0.5
  • Run the “Install CLI” plug-in
  • Execute the ./apollo-ios-cli generate command

I’m at a loss for what else to suggest to debug this right now. :thinking:

Okay, I have found the issue, it is due to my project setup. I have a Workspace which consists of: MyApp, UI, Domain, Data and Core project targets. The issue lies inside the Data project target. It is the one that has Apollo as its dependency. It consists of 2 additional targets: Data and Graph. Inside Graph i store all .swift files Apollo generates.

I was opening the project via the Workspace so I have access to all targets at once, and when I would update the dependencies it would change only the Package.resolved file for the Workspace not for Data project. The fix was to close the Workspace, open Data as a standalone project and update Apollo from there.

I think i need to simplify my project structure, but I hope this helps someone :smiley: