Local swift package with both objective-c and Swift files, using swift code in objective-c and vice versa

I have a local swift package with both 'Objective-C' and 'Swift' code. I got it working by using 2 different targets in the same package as shown below:

let package = Package(
    name: "DataStore",
    platforms: [.iOS(.v13)],
    products: [
        .library(
            name: "DataStore",
            targets: ["DataStoreObjC", "DataStoreSwift"]
        )
    ],
    dependencies: [],
    targets: [
        .target(
            name: "DataStoreObjC",
            dependencies: [],
            path: "Sources/ObjC",
            publicHeadersPath: "include"
        ),
        .target(
            name: "DataStoreSwift",
            dependencies: [],
            path: "Sources/Swift",
            publicHeadersPath: "include"
        ),
    ]
)

I can add DataStore package as local package dependency to an app or another local package.

My question is: what if I want to use the file within DataStoreObjC in DataStoreSwift and vice -versa?

As an example:

  • There is DataManager.h file within DataStoreObjC which I want to use in Repository.swift within DataStoreSwift
  • Also there is a DataHandler.swift protocol within DataStoreSwift which I want to use in DataManager.h file within DataStoreObjC.

Is there any way to achieve this?