Compiler error 'symbol multiply defined' for custom scalar class

I’m attempting to use Apollo Kotlin in a multiplatform project. In my schema, there is a custom scalar type named Long. When I compile for iOS framework, a Long class gets generated by Apollo—this conflicts with the built-in Long class already defined by Kotlin Multiplatform and results in a compiler error:

java.lang.Error: Linking globals named 'OBJC_CLASS_$_{projectName}Long': symbol multiply defined!

Is there a way to configure the class names generated by Apollo? Or perhaps a way to skip the codegen step on compile so I can manually rename the class? Any other ideas?

You can add a file named extra.graphqls with this declaration:

extend scalar Long @targetName(name: "MyLong")

and the generated name will be MyLong instead of Long

The team shared the original github comment reference with me just in case you wanted to see the PR that added@targetName.

That is exactly what I was looking for. Thanks!

1 Like