Using Perl libraries from Swift

Bit of a long shot, I know, but does anyone have experience in using Perl libraries from Swift? Presumably, by loading the Perl runtime and driving it to execute the relevant Perl library?

All I could find was the decade-old swift-perl project which gives some indication of how it could be done, but is very out of date (notably, it dates back to a time when Apple included the Perl runtime libraries & headers not just in their SDKs but in the actual OS, neither of which is the case these days).

In case it helps, I'm basically looking at exiftool. There's no native Swift equivalent, and Apple's EXIF/XMP/IPTC support is buggy and incomplete (in CGImageSource, as used by NSImage, CIImage, et al). I can shell out to the exiftool program but I'm hoping to avoid it.

1 Like

Hey @wadetregaskis
Interesting question. I would love to have PythonKit but for Perl. The Perl interpreter itself is written in c, so embedding the headers and linking the repl should be doable. I looked a while ago into this but didn't find the time to craft a working solution.

I am a bit afraid that Perl is a dead language and not much people care about it. But if there is a group of people who wants to work on it, give me a ping. I am happy to join.

1 Like

Did you make any progress with this? I have written my own exif extract routines in swift (partly so that I can get them to run under iOS and iPadOS) - but they are much more limited than exiftool (I concentrate on Fujifilm X series cameras). I would like to extend those routines - at least under MacOS - without having to learn the details of every file type and every camera. Apple support for Fujifilm cameras is extremely limited (late support for new cameras - no support for compressed raw and no support at all for maker notes exif).

For now I'm just invoking exiftool with NSProcess. It's a bit clumsy (and very inefficient), but workable.

I never really looked into running the Perl interpreter in order to run exiftool, although I imagine it's not that difficult. Folks have done similar things with various other interpreted languages without great difficulty.