I'm attempting to migrate from an Xcode-based built to SPM. I have a strange setup, which is not under my control. I've got a C-based framework MyPrivateFramework.framework, which contains neither a modulemap nor headers. While these files are not in actually in the .framework container, I have access to the needed .h files.
I've setup a very simple test like this:
MyPrivateFramework/
MyPrivateFramework/Sources/MyPrivateFramework/module.modulemap
MyPrivateFramework/Sources/MyPrivateFramework/MyPrivateFramework.h
MyPrivateFramework/Tests/MyPrivateFrameworkTests/MyPrivateFrameworkTests.swift
MyPrivateFramework/Package.swift
module.modulemap:
module MyPrivateFramework [system] {
header "MyPrivateFramework.h"
link framework "MyPrivateFramework.framework"
export *
}
Package.swift:
import PackageDescription
let package = Package(
name: "MyPrivateFramework",
platforms: [.macOS(.v10_15)],
products: [
.library(
name: "MyPrivateFramework",
targets: ["MyPrivateFramework"]),
],
dependencies: [
],
targets: [
.systemLibrary(
name: "MyPrivateFramework"),
.testTarget(
name: "MyPrivateFrameworkTests",
dependencies: ["MyPrivateFramework"],
linkerSettings: [
.unsafeFlags(["-F", "/path/to/framework/parent/directory"]),
]),
],
swiftLanguageVersions: [.v5]
)
The goal of this is just to ensure that I can successfully access the functions with MyPrivateFramework. I thought was re-creating the same configuration as what I'm using within my Xcode target, but this setup fails to link with:
ld: warning: Could not find or use auto-linked framework 'MyPrivateFramework.framework'
I've tried every combination I can think of for linkerSettings
, but it seems that nothing I can do will allow the linker to find the framework. Anyone have any ideas on how I might get this to work with SPM?