Swift Standalone Support

Are there any plans—or is there any way—to support standalone Swift? I’m building a web server back-end via Perfect which will run on Linux. I was hoping to integrate something like Sentry into it to monitor any errors that may (will) occur, but Sentry-Cocoa (understandably, given the name) doesn’t work outside of a Cocoa project.

Namely, adding .Package(url: "https://github.com/getsentry/sentry-cocoa.git", majorVersion: 3, minor: 1) to my Package.swift file, then running swift build, gives the error:

[snip]
Linking Sentry
Undefined symbols for architecture x86_64:
  "_deflate", referenced from:
      -[NSData(Compression) sentry_gzippedWithCompressionLevel:error:] in NSData+Compression.m.o
  "_deflateEnd", referenced from:
      -[NSData(Compression) sentry_gzippedWithCompressionLevel:error:] in NSData+Compression.m.o
  "_deflateInit2_", referenced from:
      -[NSData(Compression) sentry_gzippedWithCompressionLevel:error:] in NSData+Compression.m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures

tl;dr: How can I go about using Sentry via Swift without Cocoa?

Thanks,
-tlf

Hey, sorry for replying so late, didn’t see it.

I was already playing around with it and it works by telling swift to link libz.

swift build -Xlinker -lz

This should resolve your issue. Be aware that you most likely need to run this on a Mac, it will not work on linux. That’s why we didn’t promote it yet.

That’s good to know, but unfortunately I do need it to run on Linux as that is where our production server is running. I’d love to have a cross-platform solution (even without some of the bells and whistles).

Please let me know if there’s anything I can do to help!

-tlf

Also interested in this.

Has there since been any update on this? Hoping to integrate Sentry in my Vapor swift server application

Sentry doesn’t have plans to work on official Vapor support at the moment. This could change though.

Our current “Apple” SDK is optimized for client apps. macOS, iOS etc.
It won’t compile on Linux.

I started experimenting with a Swift (cross platform) SDK although it was just a few commits to define a potential structure; https://github.com/bruno-garcia/sentry-swift

If anyone wants to contribute, I can help out with guidance/code reviews from the Sentry side.