I'm trying to convert a cocoapod project to a spm library.
However, the swift target can't find this class in it's objc target dependency.
Cannot find 'RMPhoneFormat' in scope
The Resolve Packages log tells me:
public headers ("include") directory path for 'CommonsObjc' is invalid or not contained in the target
I guess my objc target can't find the headers in the folder I've specified.
What is the base directory where the publicHeadersPath
is looking for the specified folder? Isn't that a sibling folder to the path of the target?
Why is the Resolve Packages log looking for a include
directory when I specified headers
?
What am I missing / not seeing?
My Package.swift
file:
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Commons",
platforms: [
.iOS(.v15)
],
products: [
.library(
name: "Commons",
targets: [
"CommonsSwift"
]
)
],
dependencies: [
.package(url: "https://github.com/Cocoanetics/DTCoreText", exact: "1.6.26"),
.package(url: "https://github.com/ashleymills/Reachability.swift", exact: "4.3.1")
],
targets: [
.target(
name: "CommonsObjc",
path: "Commons/objc",
resources: [
.process("RMPhoneFormat/PhoneFormats.dat")
],
publicHeadersPath: "headers"
),
.target(
name: "CommonsSwift",
dependencies: [
.product(name: "DTCoreText", package: "DTCoreText"),
.product(name: "Reachability", package: "Reachability.swift"),
.target(name: "CommonsObjc")
],
path: "Commons/swift",
resources: [
.process("Helpers/airportTimeZones.dat")
]
)
]
)
File structure:
LibraryRootFolder/Commons:
.
├── Info.plist
├── Commons.h
├── headers
│ ├── Commons.h
│ └── RMPhoneFormat.h
├── objc
│ └── RMPhoneFormat
│ ├── PhoneFormats.dat
│ ├── RMPhoneFormat.h
│ └── RMPhoneFormat.m
├── swift
│ └── etc etc