Error when configuring code generation in iOS app with SPM via Xcode: Plugin doesn't support Xcode projects

I am trying to migrate from apollo 0.53.0 to 1.0.0 in an iOS project and I’m having issues.

The project I’m working on is using SPM via Xcode (as opposed to SPM via Package.swift).

I am following the instructions here, under “Swift Package Manager - Xcode”:

After adding the Apollo iOS package as a dependency for your Xcode project, right-click on your project and at the bottom of the menu you will find an ‘Apollo’ labeled group of menu items that are the plugin commands. Clicking on any of these will present another screen where you are able to add any custom arguments.

However, when I right-click on the project, then ApolloCodeGenPlugin-Initialize, I get 2 logs in the Report navigator:

  • Build Tools for plug-in “ApolloCodegenPlugin-Initialize” - Builds succeeds
  • Plug-in command “ApolloCodegenPlugin-Initialize” … - error: Plugin doesn’t support Xcode projects (it doesn’t use the XcodeProjectPlugin library)

I am stuck at this error and don’t know how to continue.

I also tried to find a tutorial that I can use as reference but the one existing here already states that “It will not be updated for the 1.x versions.”

We’re working on improving this, but this thread has the workaround for now. Update CLI docs to recommend `--disable-sandbox` · Issue #2565 · apollographql/apollo-ios · GitHub

Thanks @AnthonyMDev . I have tried to run the plugin with the --disable-sandbox parameter, as specified in the thread you linked to. However, I still get the same error.

Just for clarity, I am aiming to run the ApolloCodegenPlugin-Initialize plugin, whereas that thread seemed to refer to ApolloCodegenPlugin-Fetch plugin. I provide the schema manually, so I don’t need to fetch it in principle.

I actually recommend you try manually installing the CLI as is mentioned at the bottom of that linked thread. The --disable-sandbox is necessary when running the SPM plugin, but there are some unresolved issues right now with running the SPM plugin via Xcode. We’re working on it!

1 Like

How can we remove the plugin? It’s breaking builds. “Cannot find type ‘ApolloCodegen’ in scope”

@tlester I’ve only seen this error when trying to build ApolloCodegenLib in an iOS target, it is macOS only.

@atineoSE there was a fix for Xcode plugins in 1.0.1 which should resolve the error: Plugin doesn’t support Xcode projects (it doesn’t use the XcodeProjectPlugin library) error.

However we still do not have a workaround for the --disable-sandbox parameter which is needed for fetching a schema via the plugin.