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 withinDataStoreObjC
which I want to use inRepository.swift
withinDataStoreSwift
- Also there is a
DataHandler.swift
protocol withinDataStoreSwift
which I want to use inDataManager.h
file withinDataStoreObjC
.
Is there any way to achieve this?