What happened?
An external package may have its own dependencies. When these are built, they should be build as the same product type as the parent. For example if my dependency Apollo is built as a dynamic framework, I would expect its dependencies ApolloAPI and ApolloUtils to also be built as dynamic frameworks.
This becomes an issue if my project has two internal libraries, say, FeedFeature and ProfileFeature that both depend on Apollo. In this case, since the nested dependencies are built as static frameworks, I see a warning because they’re being linked twice (i.e. duplicated)
How do we reproduce it?
In a Package.swift, we can specify the product type of a dependency like so:
#if TUIST
import ProjectDescription
let packageSettings = PackageSettings(
productTypes: [
"Apollo": .framework
]
)
#endif
let package = Package(
name: "MyProj",
dependencies: [
.package(url: "https://github.com/apollographql/apollo-ios", exact: "0.51.0")
]
)
In the Project.swift:
let project = Project(
...,
target: [
.target(name: "FeedFeature", product: .framework, dependencies: [.external(name: "Apollo")]),
.target(name: "ProfileFeature", product: .framework, dependencies: [.external(name: "Apollo")]),
]
)
When using tuist cache both my targets will have Apollo.xcframework ApolloUtils.xcframework and ApolloAPI.xcframework linked as dependencies. This is a problem since the latter two are static and these two feature frameworks will be linked into the same app.
Error log
The following warnings need attention:
· Xcframework 'ApolloUtils.xcframework' has been linked from target 'FeedFeature' and target 'ProfileFeature', it is a static product so may introduce unwanted side effects.
· Xcframework 'ApolloAPI.xcframework' has been linked from target 'FeedFeature' and target 'ProfileFeature', it is a static product so may introduce unwanted side effects.
macOS version
14.5
Tuist version
4.23
Xcode version
15.4