I have a Swift package with two targets:
- one with Swift code ("CompositorCore") and
- one with C++/Objective-C++ code ("cpp")
// swift-tools-version: 6.0
import PackageDescription
let package = Package(
name: "CompositorCore",
platforms: [.macOS(.v10_15)],
products: [
.library(
name: "CompositorCore",
type: .dynamic,
targets: ["CompositorCore"])
],
dependencies: [
// TODO swift-log?
.package(url: "https://github.com/Quick/Nimble.git", "9.0.0"..<"9.1.0"),
.package(url: "https://github.com/Quick/Quick.git", "3.0.0"..<"3.1.0")
],
targets: [
.target(
name: "cpp",
swiftSettings: [.interoperabilityMode(.Cxx)]
),
.target(
name: "CompositorCore",
dependencies: ["cpp"],
resources: [
.copy("Resources/texlive"),
.copy("Resources/Fonts"),
.process("Resources/Images"),
.copy("Resources/templates"),
.copy("Resources/texmf"),
.copy("Resources/UserGuide"),
],
swiftSettings: [.interoperabilityMode(.Cxx)]
),
.testTarget(
name: "CompositorCoreTests",
dependencies: [
"CompositorCore",
"Nimble",
"Quick"
],
resources: [
.copy("Resources/testdata"),
.copy("../../Sources/CompositorCore/Resources/Fonts"),
.copy("../../Sources/CompositorCore/Resources/texmf"),
.copy("../../Sources/CompositorCore/Resources/texlive")
],
swiftSettings: [.interoperabilityMode(.Cxx)]
),
],
swiftLanguageModes: [.v5],
cxxLanguageStandard: .cxx11
)
The cpp module's folder structure looks like this:
karl@10 Core % tree Sources/cpp
Sources/cpp
├── EmbeddedTeX.mm
└── include
├── EmbeddedTeX.h
├── TeXErrors.h
├── cpp.h
└── tex.hpp
The cpp.h umbrella header looks like this:
#pragma once
#include <EmbeddedTex.h>
#include <tex.hpp>
#include <TeXErrors.h>
The package builds fine on macOS:
karl@10 Core % swift build -Xswiftc -suppress-warnings
Building for debugging...
[13/13] Linking libCompositorCore.dylib
Build complete! (9.31s)
Mac Swift toolchain:
karl@10 Core % swift -version
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
The problem is with the C++ code when building on Windows:
PS E:\sandbox\compositorapp\compositor\Sources\Core> swift build
...
[1/1] Planning build
Building for debugging...
In file included from E:\sandbox\compositorapp\compositor\Sources\Core\Sources\cpp\EmbeddedTeX.mm:9:
E:\sandbox\compositorapp\compositor\Sources\Core\Sources\cpp\include/EmbeddedTeX.h:9:9: fatal error: 'Foundation/Foundation.h' file not found
9 | #import <Foundation/Foundation.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
(this is the Powershell terminal inside VS Code)
The <Foundation/Foundation.h>
framework header (which is found when building on macOS) is somehow not found when building on Windows.
Am I missing header search paths for Windows in my Package.swift?
Windows Swift toolchain:
PS E:\sandbox\compositorapp\compositor\Sources\Core> swift -version
compnerd.org Swift version 6.2-dev (LLVM 9f6c3d784782c34, Swift 55189bae8e55169)
Target: aarch64-unknown-windows-msvc
Thanks in advance.