View in #support on Slack
@mollyiv: Hi Is there a documentation how to link remote binary framework as Swift package in Tuist? I didn’t see any example in fixtures project’s directory and found nothing in the docs
@Daniele_Formichelli: What problem are you facing?
It shouldn’t be different from depending on a normal product/target from a Swift package
@mollyiv: To manage dependencies in Tuist, we use Package.swift. Where should I add a binary target there? Let’s say I have a Project.swift manifest file and I have a FrameworkA. I’d like to add remote binary Swift package dependency to it.
Apple docs say to add it as .binaryTarget
in the project manifest directly. In Tuist Package.swift we cannot do that, because we’re not defining local targets there. They are defined in Project.swift.
Tell me if the problem description is clear for you
@Pedro: The guides you are reading are for distributing a binary wrapped in a package. if the package that you want to consume is already declared as stated in those guidelines, you can then add a .package(...
to your Package.swift, and SPM should resolve it
@mollyiv: Hmmm, correct me if I’m wrong, but SPM handles downloading and linking remote binary even though you don’t have a wrapper.
As long as a xcframework.zip is available to SPM, you don’t have to have a wrapper package.
I was hoping there’s a way to link it the same way in Tuist - without a wrapper package.
@Pedro: Do you have an example of an XCFramework?
@mollyiv: It’s our internal framework, cannot share it publicly. You can place a xcframework.zip at downloadable location.
Let me try find one in public.
@Pedro: You’ll have to create a local package that acts as an umbrella to pull those remote packages. AFAIK, Xcode projects don’t support that either:
@mollyiv: But there are some problems with the RxRelay signatures.
So what you’re suggesting is the umbrella local Swift package, it would pull all remote binary dependencies, define libraries a package produces, and make them visible to other packages, link the umbrella package to Package.swift Tuist file and finally, add them as .external(name: "")
in the project manifest file Project.swift?
// LocalUmbrellaPackage
let package = Package(
name: "MyLibrary",
products: [
.library(name: "MyRemoteLibrary", targets: ["MyRemoteLibrary"])
],
targets: [
.binaryTarget(
name: "MyRemoteLibrary",
url: "<https://url/to/some/remote/xcframework.zip>",
checksum: "The checksum of the ZIP archive that contains the XCFramework."
)
]
)
// Tuist Package.swift
let package = Package(
name: "MyPackage",
dependencies: [
.package(path: "../LocalUmbrellaPackage"),
]
)
// Tuist Project.swift
let project = Project(
targets: [
.target(name: "MyFramework", dependencies: [.external(name: "MyRemoteLibrary")]
]
)
Something like that?
I tried it and it seems like it worked, thanks Pedro!
Btw, I also tried to omit the wrapper package and declare target directly in Tuist’s Package.swift:
let package = Package(
name: "MyPackage",
products: [
.library(name: "MyRemoteBinary", targets: ["MyRemoteBinary"])
],
targets: [
.binaryTarget(
name: "MyRemoteBinary",
url: "https://.../MyRemoteBinary.xcframework.zip",
checksum: "xxx"
),
]
)
but got an error:
`MyRemoteLibrary` is not a valid configured external dependency
Consider creating an issue using the following link: <https://github.com/tuist/tuist/issues/new/choose>
What’s interesting, tuist downloaded the binary successfully:
~/Tuist/.build/artifacts/tuist/MyRemoteLibrary/MyRemoteLibrary.xcframework
@Pedro: The wrapper is necessary . I’ll extract this into the community forum for future reference