Search code examples
iosswiftdependency-managementswift-package-manager

Creating New Swift Package - Header Not Found


I've just created a new Objective-C library, and I'm trying to add support for Swift Package Manager.

The library itself is very basic. It has the following source structure.

ProjectName/ProjectName.h
ProjectName/ProjectName.m
ProjectName/Private/ProjectNameInternal.h
ProjectName/Private/ProjectNameInternal.m

The public source file imports the private header, and the private source file imports the public header. When I made a basic Package.swift and tried build it, it gave me the error that the private header cannot see the public one.

Is there a special way I'm supposed to declare all of these Objective-C headers?

(This is the library in question if it helps.)

Build Error


Solution

  • I think you need to specifically add to your header search paths via cSettings. Ex:

    .target(
        ...
        cSettings: [
        .headerSearchPath("ProjectName"),
        .headerSearchPath("ProjectName/Private"),
        ]
    )