Hello!
First of all I would like to apologise if this is a very basic question, or if this is not the correct place to ask.
I've been working on a rendering project lately to learn about graphics programming with Metal. I was now looking for a physics library to use, and bullet seems like a fairly well documented one so I decided to give that a shot. However I have not been succesful in including it in my project.
My project is set up to use different local Swift Packages that get imported as needed. So in this case my issue lies with my "IAEPhysics" package.
it has the following structure:
IAEPhysics/
βββ README
βββ Package.swift
βββ Sources/
. βββ IAEPhysics/
. . . βββ shim.h
. . . βββ module.modulemap
. βββ IAEBullet/
. . . βββ PhysicsController.swift // here I import IAEBullet
So the idea is here that my physics controller takes care of physics related things while making use of bullet, thus bullet does not necessarily need to be exposed outside of the package.
First I tried to make a separate package out of bullet similarly as described here:
But that seems to have been outdated and this should have been the current way to do it:
I also came across another post here: How do I fix linkages for a system-module package following a brew update?
And I found a relevant repository on OP's github: GitHub - spencerkohan/Swift-Cbullet: A swift system module for the Bullet Physics
However I've yet to find the correct way to put this information together to get it to work. Hopefully someone here can point me in the right direction.
Package.swift
import PackageDescription
let package = Package(
name: "IAEPhysics",
platforms: [.macOS(.v11)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "IAEPhysics",
targets: ["IAEPhysics"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(path: "../IAEFoundation"),
],
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 this package depends on.
.target(
name: "IAEPhysics",
dependencies: ["IAEFoundation", "IAEBullet"]),
.systemLibrary(name: "IAEBullet", pkgConfig: "bullet", providers: [.brew(["bullet"])]),
.testTarget(
name: "IAEPhysicsTests",
dependencies: ["IAEPhysics"]),
]
)
module.modulemap
module IAEBullet [system] {
// header "btBulletCollisionCommon.h"
umbrella header "shim.h"
link "bullet"
link framework "BulletDynamics"
link framework "BulletCollision"
export *
}
shim.h
#include <BulletCollision/btBulletCollisionCommon.h>
#include <BulletDynamics/btBulletDynamicsCommon.h>
The errors I'm seeing now are:
- Could not build Objective-C module 'IAEBullet'
- A number of errors similar to: Unknown type name 'class'; did you mean 'Class'? (also for 'false' , 'btScalar', 'bool', ...)
What is the correct way to do this? Is it even possible to do this? In case not, what would be a good alternative way, or an alternative framework that I could use?
Thanks a lot in advance and have a nice day!