I followed the documentation in getting-started with 1.0.5. It stated for SPM to just add Apollo.
Leading to in ObjectFileGenerator.swift, LocalCacheMutationDefinitionTemplate.swift:
let config: ApolloCodegen.ConfigurationContext
//Cannot find type 'ApolloCodegen' in scope
Installing ApolloCodegen does also not help
Hi @tzdesign
The Getting Started guide has instructions for using the Install CLI plugin to have the CLI built for you and put into your project path, which is what you would then use to initialize the codegen configuration and generate Swift code from your schema and operations.
How are you getting ObjectFileGenerator.swift and LocalCacheMutationDefinitionTemplate.swift into your project? They shouldn’t be there unless you’re pulling the ApolloCodegenLib package into your project and that package is also macOS only.
1 Like
Hi @calvincestari
I’m confused as well. I will check this out. It points out that the code gen binary is included in the plain Apollo package? I would say it might be one of these 3 things:
- SPM cache in Xcode would not be the first rodeo
- checked the api-iOS-cli in the package manager
- target is for macOS and iOS
I will test it on Friday on a clean slate and will write an update.
Thank you very much for the swift answer
Btw the code completion worked without a problem.
It’s the last part of the package. If you click on apollo-ios-cli in the Xcode SPA, you will have a bad time.
If this executable is so embedded, why is it even a possible choice here?
Anyway this is fixed.
What I’m totally missing in the docs is the description of how to get moduleType swiftPackageManager working in xCode. I spend way to much time and dragging it over with the option copy files was not working for me. Will try to use moduleType embeddedInTarget now.
Is there a way to close this here?
It’s the last part of the package. If you click on apollo-ios-cli in the Xcode SPA, you will have a bad time.
If this executable is so embedded, why is it even a possible choice here?
The CLI is defined as a product because that’s how we distribute a compilable executable. If you look inside Package.swift you’ll see there is an executableTarget too but building that doesn’t produce a binary file; the executable product is needed to do that.
What I’m totally missing in the docs is the description of how to get moduleType swiftPackageManager working in xCode. I spend way to much time and dragging it over with the option copy files was not working for me.
Once you’ve generated the Swift package you will need to add it as dependency, just as you added Apollo iOS to your project, but this time it is a local dependency. The last step after that is to link the new library to your target.
In this screenshot it shows how to add a generated Swift package named MyAppAPI
, to the target of a project SampleProject
.
Is there a way to close this here?
No, these are community discussions not issues.
1 Like
Thanks a lot.
I got it to work as SPM package yesterday after lunch. Saw another ticket about that. Xcode sucks hard in that matter and no good docs about that from Apple. The best thing would be adding these screenshot with a bit of text to the docs.
Have a great weekend @calvincestari
1 Like