Skip to content

Commit

Permalink
Add support for adding this lib to multi-platform targets where only …
Browse files Browse the repository at this point in the history
…used for iOS
  • Loading branch information
Jeehut committed May 24, 2024
1 parent 944a6a1 commit e993185
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
28 changes: 5 additions & 23 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "CodeScanner",
platforms: [
.iOS(.v13)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "CodeScanner",
targets: ["CodeScanner"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "CodeScanner",
dependencies: []),
]
platforms: [.iOS(.v13), .macOS(.v10_15), .tvOS(.v13), .visionOS(.v1), .watchOS(.v6)],
products: [.library(name: "CodeScanner", targets: ["CodeScanner"])],
dependencies: [],
targets: [.target(name: "CodeScanner", dependencies: [])]
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2024 Paul Hudson. All rights reserved.
//

#if os(iOS)
import AVFoundation

@available(macCatalyst 14.0, *)
Expand Down Expand Up @@ -79,6 +80,7 @@ private extension Float {
self * Float.pi / 180
}
}
#endif

/*
Part of this code is copied from Apple sample project "AVCamBarcode: Using AVFoundation to capture barcodes".
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodeScanner/CodeScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2021 Paul Hudson. All rights reserved.
//

#if os(iOS)
import AVFoundation
import SwiftUI

Expand Down Expand Up @@ -153,3 +154,4 @@ struct CodeScannerView_Previews: PreviewProvider {
}
}
}
#endif
2 changes: 2 additions & 0 deletions Sources/CodeScanner/ScannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2021 Paul Hudson. All rights reserved.
//

#if os(iOS)
import AVFoundation
import UIKit

Expand Down Expand Up @@ -594,3 +595,4 @@ public extension AVCaptureDevice {
}

}
#endif

0 comments on commit e993185

Please sign in to comment.