import PackageDescription
let package = Package(
name: "SuperLibrary",
products: [
.library(
name: "SuperLibrary",
type: .dynamic,
targets: ["SuperLibrary"]),
],
targets: [
.target(name: "SuperLibrary",
path: ".",
exclude: [],
sources: ["Core", "Dependencies/OneDependency/OneDependency.m"],
publicHeadersPath: "Core"), // OneDependency.h is not public, it is private and had been added by hands as plain sources.
]
)
There is no warnings in REPL, but, it doesn't compile. Build action fails because SwiftPM can't find any of my header files ( umbrella or non-umbrella ). Also it can't handle neither framework #import <SuperLibrary/File.h> nor plain #import "File.h" ).
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "SuperLibrary",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SuperLibrary",
type: .dynamic,
targets: ["SuperLibrary"]),
],
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: "SuperLibrary",
path: "Sources",
exclude: [],
sources: ["Core", "Dependencies/OneDependency/OneDependency.m"],
publicHeadersPath: "Core"),
.testTarget(
name: "SuperLibraryTests",
dependencies: ["SuperLibrary"]),
]
)
Maybe this is what you need. No need to create include directory.
Can you share example project?
By the way, neither of these headers are included into each other.
So, they are pure public headers without headers imports?
Import statements in this example has relative paths.
So, I have reached "alternative" solution by putting all headers in "Core/Include" directory.
Ugly, though.
I still have issues with test targets. Headers can not be marked as public or private.
By the way, .testTarget even doesn't have headers, thus, it is impossible to mix helpers/scaffolding/fixtures and test targets.
Since I can't use framework import #import <Library/Umbrella.h> ( because umbrella contains framework imports, hah ), I change imports to modern style @import Library;
Everything works fine in Xcode, but I can't build package from command line: swift build throws error: "@import Library; - module not found".
As I mentioned above, I can build package in Xcode and even run tests, but command line swift build/test doesn't work at all.
Xcode 11.4 Beta2 (Doubt this is a feature or bug) now totally break publicHeadersPath usage, anything other than .h header file, will be ignored in Xcode's compile sources when put it under publicHeadersPath.
Means:
MyRepo
Sources
-- Foo.h
-- Foo.m
-- Foo.cpp
-- Foo.c
using
path: "Sources"
publicHeadersPath: "."
Now all the source code will been ignored, this trick not work any more
You have to arrange folder strcuture, or create symbol link like this