iosswiftxcodeswift-package-manager

Swift Package Manager Transitive Local Dependency - package depends on local package, which is not supported


I have an iOS multi-repository app that uses cocoapods to sync multiple frameworks, I am trying to migrate to swift package manager whoever I'm facing some issue while trying to connect all dependencies, this is my architecture:

My app is in one repo and the rest of the packages are in a different repo, the package is a feature module, that is modularized internally to separate UI, Business Logic and networking layer, each of them is a different package, here is a diagram that explains it better:

Architecture diagram

Since MultiFrameWorkPackage has a dependency on other frameworks I need to reference it locally, however when I try to fetch MultiFrameWorkPackage remotely from MyApp.xcodeproj I am getting following error:

package 'multiframeworks' is required using a revision-based requirement and it depends on local package 'frameworka', which is not supported

Is there any workaround to achieve this kind of architecture with SPM?

Here are code examples, you can even try running it:

Repo 1: https://github.com/lalejzapata/MyMainApp

Repo 2: https://github.com/lalejzapata/MultiFrameworks


Solution

  • Finally it worked, at first i wanted to have different Package.swift files and sync all of them as individual packages, I ended up having only 1 Package.swift that syncs all files and targets, here are some key points, and final Package.swift file:

    .

    let package = Package(
    name: "MultiFrameworksPackage",
    products: [
        .library(
            name: "MultiFrameworksPackage",
            targets: ["MultiFrameworks", "FrameworkA", "FrameworkB"]
        )],
    targets: [
        .target(
            name: "MultiFrameworks",
            dependencies: [
                "FrameworkA"
            ],
            path: "Sources"
        ),
        .target(
            name: "FrameworkA",
            dependencies: [
                "FrameworkB"
            ],
            path: "FrameworkA"
        ),
        .target(
            name: "FrameworkB",
            dependencies: [
            ],
            path: "FrameworkB"
        )
    ]
    

    )