Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Schema package using wrong import statements #2663

Closed
StarLard opened this issue Nov 14, 2022 · 5 comments · Fixed by #2677
Closed

Generated Schema package using wrong import statements #2663

StarLard opened this issue Nov 14, 2022 · 5 comments · Fixed by #2677
Assignees
Labels
bug Generally incorrect behavior codegen Issues related to or arising from code generation needs investigation

Comments

@StarLard
Copy link

Bug report

When you specify swiftPackageManager module type to generate code, the generated Schema files will use import Apollo instead of import ApolloAPI, which generates the compiler error "No such module 'Apollo'"

Versions

Please fill in the versions you're currently using:

  • apollo-ios SDK version: 1.0.3
  • Xcode version: 14.0.1
  • Swift version: 5.7
  • Package manager: SPM

Steps to reproduce

  1. Generate code using the swiftPackageManager module type
  2. Add generated Swift Package to target
  3. Attempt to build project
  4. Observe error
@StarLard
Copy link
Author

After deleting everything and regenerating from scratch, it seems this is caused by using swiftPackageManager in conjunction with the cocoapodsCompatibleImportStatements option. So the bug is actually that the cocoapodsCompatibleImportStatements option is being propagated to the files generated for SPM, not just the generated operation files.

@calvincestari
Copy link
Member

Hi @StarLard 👋🏻 - thanks for the bug report.

The combination of cocoapodsCompatibleImportStatements with a module type of other is the correct usage of those two properties. I think the bug is that we don't have a check to disallow cocoapodsCompatibleImportStatements when using swiftPackageManager.

Check in your config file what the value of cocoapodsCompatibleImportStatements is and set it to false; that will generate the correct import statements. I'll do some testing for cocoapodsCompatibleImportStatements + swiftPackageManager and get a fix in if needed.

@calvincestari calvincestari added bug Generally incorrect behavior needs investigation labels Nov 15, 2022
@calvincestari calvincestari self-assigned this Nov 15, 2022
@calvincestari calvincestari added the codegen Issues related to or arising from code generation label Nov 15, 2022
@StarLard
Copy link
Author

I was hoping to add my generated files to a target that has Apollo installed via cocoapods and bring in my schema types module via SPM, but I guess that would mean having two Apollo installations so yeah, it would be nice if this configuration wasn't available.

@calvincestari
Copy link
Member

Yeah, that's not a configuration we support.

@calvincestari
Copy link
Member

@StarLard, this is now fixed and will be included in the 1.0.4 release. An error will now be thrown if the config has conflicting values. Thanks for reporting this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior codegen Issues related to or arising from code generation needs investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants