Skip to content

Commit 23e9b6e

Browse files
authored
Merge pull request #145 from Jeehut/main
Add support for adding this lib to multi-platform targets
2 parents 944a6a1 + f3586ac commit 23e9b6e

File tree

5 files changed

+13
-27
lines changed

5 files changed

+13
-27
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ on:
88

99
jobs:
1010
build:
11-
1211
runs-on: macos-latest
13-
1412
steps:
1513
- uses: actions/checkout@v2
16-
1714
- name: Select Xcode Version
1815
uses: maxim-lobanov/setup-xcode@v1
1916
with:
2017
xcode-version: latest-stable
21-
2218
- name: Show eligible build destinations
2319
run: xcodebuild -showdestinations -scheme CodeScanner
2420
- name: Build ( iOS)
2521
run: xcodebuild build -scheme CodeScanner -destination 'platform=iOS Simulator,OS=latest,name=iPhone 13 Pro'
22+
- name: Build ( visionOS)
23+
run: xcodebuild build -scheme CodeScanner -destination 'platform=visionOS Simulator,OS=latest,name=Apple Vision Pro'
2624
- name: Build ( mac Catalyst)
2725
run: xcodebuild build -scheme CodeScanner -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst'

Package.swift

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
1-
// swift-tools-version:5.3
2-
// The swift-tools-version declares the minimum version of Swift required to build this package.
3-
1+
// swift-tools-version:5.9
42
import PackageDescription
53

64
let package = Package(
75
name: "CodeScanner",
8-
platforms: [
9-
.iOS(.v13)
10-
],
11-
products: [
12-
// Products define the executables and libraries produced by a package, and make them visible to other packages.
13-
.library(
14-
name: "CodeScanner",
15-
targets: ["CodeScanner"]),
16-
],
17-
dependencies: [
18-
// Dependencies declare other packages that this package depends on.
19-
// .package(url: /* package url */, from: "1.0.0"),
20-
],
21-
targets: [
22-
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
23-
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
24-
.target(
25-
name: "CodeScanner",
26-
dependencies: []),
27-
]
6+
platforms: [.iOS(.v13), .macOS(.v10_15), .tvOS(.v13), .visionOS(.v1), .watchOS(.v6)],
7+
products: [.library(name: "CodeScanner", targets: ["CodeScanner"])],
8+
dependencies: [],
9+
targets: [.target(name: "CodeScanner", dependencies: [])]
2810
)

Sources/CodeScanner/AVCaptureDevice+bestForBuiltInCamera.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2024 Paul Hudson. All rights reserved.
77
//
88

9+
#if os(iOS)
910
import AVFoundation
1011

1112
@available(macCatalyst 14.0, *)
@@ -79,6 +80,7 @@ private extension Float {
7980
self * Float.pi / 180
8081
}
8182
}
83+
#endif
8284

8385
/*
8486
Part of this code is copied from Apple sample project "AVCamBarcode: Using AVFoundation to capture barcodes".

Sources/CodeScanner/CodeScanner.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2021 Paul Hudson. All rights reserved.
77
//
88

9+
#if os(iOS)
910
import AVFoundation
1011
import SwiftUI
1112

@@ -153,3 +154,4 @@ struct CodeScannerView_Previews: PreviewProvider {
153154
}
154155
}
155156
}
157+
#endif

Sources/CodeScanner/ScannerViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2021 Paul Hudson. All rights reserved.
77
//
88

9+
#if os(iOS)
910
import AVFoundation
1011
import UIKit
1112

@@ -594,3 +595,4 @@ public extension AVCaptureDevice {
594595
}
595596

596597
}
598+
#endif

0 commit comments

Comments
 (0)