Hello All,
I have a project that has several third-party packages that I do not have to source to. I know SPM prefers having the source distribution, but I don't have that option. Some of these are delivered as Frameworks, some are a bunch of header files and a static library. From what I read about SPM, it has System Modules which let you link in system libraries, but I am unsure if that will work with these third party code libraries.
So I have three questions.
Should SPM find the frameworks if they are in the Source folder for the project? It seems that I must pass in the frameworks path to the build command to get them to link.
How do define my own wrapper for the loose library? I don't think a system module will work because it must specify a fixed path in the module definition file. Is that correct?
Other modules I do have the source but it is in Objective-C. I am confused about how I tell SPM to build a Framework, and which files are the ones that should be exposed outside the module.
Just to follow up on the last question, I created a simple Obj-C package with DeviceUtil. I use SPM to generate the Xcode project and change the IPHONEOS_DEPLOYMENT_TARGET=9.3, SDKROOT="iphoneos" then build.
➜ DeviceUtil git:(SwiftPM) ✗ more Package.swift
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "DeviceUtil",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "DeviceUtil",
targets: ["DeviceUtil"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "DeviceUtil",
dependencies: ),
publicHeadersPath: "DeviceUtil/include"),
.testTarget(
name: "DeviceUtilTests",
dependencies: ["DeviceUtil"]),
]
)
Ah, swift package generate-xcodeproj does not seem to add the Headers build phase and the defines module flag even though I added the publicHeadersPath.