I wonder if its possible to get target based dependency using Swift Package Manager without Xcode resolving all dependency in package.
I have a package like this:
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "ReCaptcha",
platforms: [
.iOS(.v9)
],
products: [
.library(
name: "ReCaptcha",
targets: ["ReCaptcha"]),
.library(
name: "ReCaptchaRx",
targets: ["ReCaptchaRx"])
],
dependencies: [
.package(url: "https://github.com/ReactiveX/RxSwift.git", from: "6.0.0"),
.package(url: "https://github.com/JakubMazur/AppSwizzle.git", from: "1.3.2"),
],
targets: [
.target(
name: "ReCaptcha",
dependencies: [],
path: "ReCaptcha/Classes",
exclude: ["Rx"],
linkerSettings: [
.linkedFramework("UIKit")
]
),
.target(
name: "ReCaptchaRx",
dependencies: [
"ReCaptcha",
.product(name: "RxSwift", package: "RxSwift")
],
path: "ReCaptcha/Classes/Rx",
linkerSettings: [
.linkedFramework("UIKit")
]),
.testTarget(
name: "ReCaptcha_Tests",
dependencies: ["ReCaptcha", "AppSwizzle"],
path: "Example/ReCaptcha_Tests",
exclude: ["Info.plist"],
resources: [
.copy("mock.html")
])
]
)
So it contains RxSwift
as a dependency to 1 of 2 targets.
So what I wanted to happen is that if I import only one target:
This will NOT resolve RxSwift
in project
Instead it's getting resolved but it's anyway unavailable to import:
Original autor of this library using AppSwizzle
library for testTarget and then it's not getting resolved as expected, but why then importing only target without dependency resolve dependency to other target?
This is open source, so code is available: https://github.com/JakubMazur/ReCaptcha/pull/1