Using c binding/linking with the package.swift and getting an error with linking to the folder

So I feel kind of embarrased to share this, but I am working on a Raylib binding for 5.0 since the current one is out of date and uses an older swift.
Before, I had this working with a simple shell script because I ended up binding it by hand at the root of the project next to the package.swift
As I moved it around to be more 'PM compliant' I get some interop errors. I think the issue is that a combination of the documentation for binding with a C library is sparse and unspecific.
And the default 'package' project recommended is a pure swift project.
I have posted my repo on github and if you technically move the files out of Sources folder, back next to the manifest and run the shell file (on linux) it will work fine.

I am sorry if this is unspecific/kind of general, this is not my first frustrations with the package manager and when I get it working with Raylib finally, but only with the compiler, I tend to get frustrated with the package manager because it is frankly causing me issues like this.

My raylib binding (semi-working)

As noted, it uses a module.modulemap for the include. And while the directory are linux-based on my machine, they are absolute paths. I would ideally just like to link the big folder to my Sources and not have to worry about it.

For reference, the manifest is partially ai-generated but I could never make these things by hand. Before it was just a 'blank' manifest.

Any general guidance please would be appreciated! I also had a semi-related post here in the past, but partly the solution did not really work since the manifest was too old/did not work locally and it used a different binding method.

I am on Pika OS (which is basically ubuntu-based) and using the 6.1 preview, I believe (I think I built it from source)

1 Like

Hey, don't know if you already figured something else by now, but recently had a similar endeavour in building a project with the plain c raylib (as the swift package seems pretty much abandoned), what I could get still is not too fancy, but it could help you with anything? or we get to a better solution together

wrote a kind of step-by-step blog post on how I did first get to integrate it on a project how to build a simple raylib project with swift | Derg Social

personally my preference is in linking raylib statically, as it is more universal than linking to shared libraries and expecting them to be on a specific path

though on that post I'm still compiling raylib separate from the swift package, it could be added as part of your build.sh or the like

and with that also made a little program to test using rayblib in an actual project sirlan/game-of-life_swift_raylib: a simple 'game of life' made using raylib in swift - Codeberg.org, which I guess is a bit more organised as the raylib folder is inside Sources/ so you don't need a separate path: field

it still is kinda hacky (both the program code and how I include raylib in the repo), so to not have to put binaries on a repo, including raylib as a git submodule and requiring a pre-compile step (also copy the module.modulemap into Sources/raylib) would probably be the more proper solution

I honestly do agree that the documentation on the compiler is pretty lacking, especially with this interop feature (and the modulemap where it just links to the clang page, which by itself is not very 'first time friendly')

1 Like