Closed akaibukai closed 3 months ago
By googling a little bit I was able to get how to add a package in a swift package, so I did the following on on Pckage.swift
dependencies: [
.package(
name: "silica",
url: "https://github.com/PureSwift/Silica",
.upToNextMinor(from: "1.3.2")
),
Then I just replaced import CoreGrphics
by import Silica
in the first module it was failing, i.e. QRCode+Builder.swift
But I got an error about incompatible tools version..
error: Dependencies could not be resolved because 'silica' contains incompatible tools version (3.0.2) and root depends on 'silica' 1.3.2..<1.4.0.
I guess that this package is simply way too old...
It seems there is not really another drop-in replacement that will work on Linux.. Too bad :(
Edit: I found the following library: https://github.com/fwcd/swift-graphics
This one is not old, and they are referencing the Cairo
library for Linux..
It seems this one was also used in the package above.
So it seems that indeed Cairo
is NOT a drop-in replacement for CoreGraphics
and that the library above (Silica) tried to be a wrapper..
Seems I'm stuck and won't be able to even test this library :(
Unless I try on a mac...
PS: will keep it open a little just to read for any comment juts in case... Then will close it.. Dragonf, you can also simply close it as well :)
Hi @akaibukai, thanks for the lovely comments!
Unfortunately this library doesn't support non-Apple platforms. As you've found, CoreGraphics isn't available on Linux (or Windows) and it would be a BIG job to rewrite the 'arty' parts to support a different rendering library. I've thought a number of times about how I would go about making this truly cross-platform but I haven't had the impetus to move forward on it.
I've never heard of Silica - it looks very promising but I notice that it hasn't been updated since 2018 (and hasn't been updated to Swift 5 either). I'll have a wander through it.
Sorry to be the bearer of bad news.
@dagronf Hey :wave: Thank you very much for your reply! You don't need to be sorry :)
I'll ask a friend with a mac to build and give me the binary.. Hoping it'll be compatible to run on Linux once build on Mac...
Little update: I have a friend that was able to build the binary on his mac easily using swift build -c release --product qrcodegen
and sent the binary to me..
As I was expecting I got the following error when I run it on my Linux:
exec: Failed to execute process: './qrcodegen' the file could not be run by the operating system.
I also tried running it within the Swift docker container and this time I'm getting the following error:
./qrcodegen: cannot execute binary file: Exec format error
I wonder if we need to set some dedicated flags for a cross platform build?
Edit: I wonder if it's not because of being built on ARM mac?
@akaibukai you will not be able to run this on a non-apple platform, as CoreGraphics only exists for Apple. Compiling on macOS and copying to Linux will not work.
Cross-compiling will only work if we replace all the CoreGraphics code in this library with a cross-platform replacement, which is a huge challenge.
Hello and thanks for this amazing library!
I hope it's the right place to post this, otherwise I'll be happy to close the issue.
So, I wanted to try it using a binary as I have absolutely no experience with any Swift/macOS/iOS etc. projects. Then I went ahead and simply tried to generate the binary using the provided command (on Linux):
I got the following error, (full ouput at the very bottom):
I tried to search on the internet, it seems CoreGraphics is a thing in Apple computers? Is there any alternative I can use on Linux?
I found for example the following library: https://github.com/PureSwift/Silica It says
Pure Swift CoreGraphics (or Quartz2D) implementation (Supports Linux)
If I replace anyimport CoreGraphics
withimport Silica
will it work?FWIW, I'm running the official swift docker container
swift:5.10
Maybe I need to install some dependencies in the container?PS: Here is the complete output: