twostraws / CodeScanner

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
MIT License
986 stars 272 forks source link

Add support for adding this lib to multi-platform targets #145

Closed Jeehut closed 1 month ago

Jeehut commented 1 month ago

I'm working on a new app that is available on all Apple platforms. But only on iOS I want to use this library to securely transfer some credentials from the Mac app to the iPhone app. But due to limitations in SwiftPM or Xcodes build system, it's not possible to include this package to a multi-platform project and just to link it when building for iOS. I'd need to create multiple targets to do that, which I don't want to do as it's a SwiftUI app and I like to keep things simple & clean.

This PR adds building support for other Apple platforms by specifying compatibility in the Package manifest while basically commenting out all code when those platforms are targeted during a build.

I'd understand if you don't want to merge this. But I needed it, so I figured maybe others may need it as well. Thank you for providing this great lib, it was a huge time saver!

twostraws commented 1 month ago

Thank you! This mostly looks good, but why the bump to Swift tools 5.9?

Jeehut commented 1 month ago

@twostraws Because I can't specify the platform .visionOS(.v1) in earlier versions, the compiler says it doesn't know what visionOS is in earlier Swift. Or maybe I'm doing something wrong? 🤷‍♂️

twostraws commented 1 month ago

Hmm. This seems like a bigger change, then. @nathanfallet: do you have any views on this? At least 5.9 isn't the newest

nathanfallet commented 1 month ago

I'm going to take a look, we had a lot of issues we solved at SQLite.swift regarding visionOS, so I should be able to find how to make it work EDIT: It looks fine to me about the Package.swift itself, the older build tool doesn't know about visionOS so there is no other choice to update.

GayleDDS commented 1 month ago

Couldn't you use #if compiler(>=5.9) for the vision stuff and not update swift-tools-version?