- This stage works just fine, at the end of the stage we have a
.build folder with the expected files.
- Running a complete clean (ie remove the
.build folder and the .xcodeproj folder) and then swift package generate-xcodeproj generates the .build folder but no module map or .o files etc. Running the tests from with Xcode, build fine and the tests run.
At this point, having run the build and test phase either via Xcode or SPM we have a .build folder.
If we run the command swift test then as expected the .build folder contains the subfolder x86_64-apple-macosx10.10 that contains the debug or release build and the the module map files such as
debug/CTulipIndicators.build/module.modulemap etc, i.e. the missing module.map file
If we elide this step i.e just run swift package generate-xcodeproj then the module map for the embedded C library resides in Dependencies.xcodeproj/GeneratedModuleMap/CLibrary/module.map
This I assume is correct as it makes sense (at least to me)
However when the Dependencies .xcodeproj is added to the MacOS application this path seems to be lost.
I have setup the Dependency package as follows:
import PackageDescription
let package = Package(
name: "Dependencies",
products: [
.library(
name: "Dependencies",
targets: ["Dependencies"]),
],
dependencies: [
.package(url: "https://github.com/lbdl/SwiftTulipIndicators.git", from: "0.1.1"),
],
targets: [
.target(
name: "Dependencies",
dependencies: ["SwiftTulipIndicators"]),
.testTarget(
name: "DependenciesTests",
dependencies: ["Dependencies"]),
]
)
The package that uses the embedded C library is setup as follows:
import PackageDescription
let package = Package(
name: "SwiftTulipIndicators",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SwiftTulipIndicators",
targets: ["SwiftTulipIndicators"]),
],
dependencies: [
.package(url: "https://github.com/lbdl/CTulipIndicatorsPackage.git", from: "0.0.2"),
.package(url: "https://github.com/Quick/Quick.git", from: "1.3.2"),
.package(url: "https://github.com/Quick/Nimble.git", from: "7.3.1"),
],
targets: [
.target(
name: "SwiftTulipIndicators",
dependencies: ["CTulipIndicators"]),
.testTarget(
name: "SwiftTulipIndicatorsTests",
dependencies: ["SwiftTulipIndicators", "Quick", "Nimble"]),
]
)
and finally the wrapped C Library package is as follows:
import PackageDescription
let package = Package(
name: "CTulipIndicators",
products: [
.library(name: "CTulipIndicators", targets: ["CTulipIndicators"]),
],
targets: [
.target(
name: "CTulipIndicators", path: "./Sources/libtulip"),
]
)
the repos for both are as follows:
CLibWrapper
DownstreamWrapper
Perhaps it's down to the way I have setup the packages?
Regardless the error can be fixed with the not ideal -Xcc flag as before but this time pointing to the module map contained in the added Dependencies package project as follows:
with the path to the GeneratedModuleMap folder of the Dependency project
some thing like -Xcc -fmodule-map-file=path/to/dependency/project/DependencyProject.xcodeproj/GeneratedModuleMap/ModuleThatsGoneMissing/module.map
I'm not sure wether this is an ID10t error on my part or an Xcode bug.
This may be useful documentation none the less. Should I put this somewhere else or just file a bug and if so where?