How to create a C library that supports both cocoa pods and SPM


I've been trying to create a library that includes a Swift wrapper over some C code. I'm trying to make the library work across both SPM and cocoa pods. I've been able to get each of them working on their own but I haven't been able to get them to work together.

├── Package.swift
├── Sources
│   ├── wrapper.swift
│   └── libCLibrary
│       ├── cLibrary.c
│       └── include
│           ├── cLibrary.h
│           └── module.modulemap
└── cLibrary.podspec

This is how I have my directory setup. It works for SPM but, I cocoapods is not able to find the cLibrary files. The way I got cocoapods to work is to move the modulemap and the header outside include. However there does not seem to be any way to get that configuration to work with SPM. Any help would be great.


Try setting it up for CocoaPods and then customizing path, exclude, sources and/or publicHeadersPath in your Package.swift.

Thanks. I was able to make it work using exclude.