I am creating local swift packages to modularize generated GraphQL binding types for my project, but I'm running into a duplicate symbols runtime warning
objc[15506]: Class CommonGraphQL19MyMutation is implemented in both
/Library/Developer/Xcode/DerivedData/MyWorkspace-gkepkcvrwzwxmzcclfsfnzqmndhy/Build/Products/Debug-iphonesimulator/PackageFrameworks/
CommonGraphQL.framework/CommonGraphQL
and
/Library/Developer/Xcode/DerivedData/MyWorkspace-gkepkcvrwzwxmzcclfsfnzqmndhy/Build/Products/Debug-iphonesimulator/PackageFrameworks/
AppAGraphQL.framework/AppAGraphQL. One of the two will be used. Which one is undefined.
I'm also getting a crash in the Apollo library
Could not cast value of type 'Swift.AnyHashable' (0x1f06d4898) to 'ApolloAPI.GraphQLEnum<CommonGraphQL.CommonGraphQL.MyType>' (0x11699a288).
The package set up is like so:
products: [
.library(name: "CommonGraphQL", type: .dynamic, targets: ["CommonGraphQL"]),
.library(name: "AppAGraphQL", type: .dynamic, targets: ["AppAGraphQL"]),
.library(name: "AppBGraphQL", type: .dynamic, targets: ["AppBGraphQL"]),
],
targets: [
.target(
name: "CommonGraphQL",
dependencies: [
.product(name: "Apollo", package: "apollo-ios"),
.product(name: "ApolloAPI", package: "apollo-ios"),
]
),
.target(
name: "AppAGraphQL",
dependencies: [
"CommonGraphQL",
.product(name: "Apollo", package: "apollo-ios"),
.product(name: "ApolloAPI", package: "apollo-ios"),
]
),
.target(
name: "AppBGraphQL",
dependencies: [
"CommonGraphQL",
.product(name: "Apollo", package: "apollo-ios"),
.product(name: "ApolloAPI", package: "apollo-ios"),
]
),
My project dependency graph is roughly:
Core.framework (dylib)
- links to CommonGraphQL.dylib (not embedded)
CoreUI.framework (dylib)
- links to Core, CommonGraphQL.dylib (not embedded)
AppA
- links to Core, CoreUI, AppAGraphQL.dylib (embedded)
AppB
- links to Core, CoreUI, AppBGraphQL.dylib (embedded)
I did some background reading on dynamic vs static linking, and so I assumed by making my GQL targets dynamic, I would avoid these duplicate symbols by only embedding my AppAGraphQL
and AppBGraphQL
packages in my AppA
and AppB
targets (respectively)
Observations
- The runtime crashes only seem to occur when I also see the duplicate symbols warning in the logs
Questions
-
Why would I see duplicate symbol warnings when both my
CommonGraphQL
andAppXGraphQL
targets are dynamically linked? -
Am I over-indexing on these duplicate symbol warnings? It's odd to me that my crash is occuring in the Apollo library
Any help would be greatly appreciated!