Swift Standalone Support


#1

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


#2

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.


#3

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


#4

Also interested in this.