I'm trying to share a dependency between my the targets of my Xcode project and a Swift Package (part of the same project) but I'm getting a duplicate symbols error with both dynamic and static targets.
I have 3 targets: App - Cocoa Touch, Module A - Static Framework, Module B - Static Framework, and a Swift Package called shared (produces a static library).
I'm trying to share RxSwift between all the targets and the shared package.
Is there any recommended approach for this? Also, I'm curious if dynamic or static frameworks are more recommended.
This is how my project looks like:
Here's how the dependency graph looks like:
- App -> Authentication, Core
- Authentication -> Core, ApiClient
- Core -> ApiClient
Here's my Package.swift
let package = Package(
name: "ApiClient",
platforms: [.iOS(.v12)],
products: [
.library(name: "ApiClient", targets: ["ApiClient"]),
],
dependencies: [
.package(url: "https://github.com/ReactiveX/RxSwift.git", from: "5.0.0"),
],
targets: [
.target(name: "ApiClient", dependencies: ["...", "RxSwift"]),
.testTarget(name: "ApiClientTests", dependencies: ["ApiClient"]),
]
)
What I'm trying to achieve is to reuse RxSwift in both my Swift Package and other targets but I get duplicate symbols error for RxSwift.
