diff --git a/Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.pbxproj b/Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.pbxproj index 997ff15..7d96d33 100644 --- a/Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.pbxproj +++ b/Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.pbxproj @@ -102,7 +102,6 @@ D50BE3F31C9FE8870000A34C /* Resources */, E090C912AA824DD28A310598 /* [CP] Embed Pods Frameworks */, C6637BE832A43C8F49FCF84D /* 📦 Embed Pods Frameworks */, - A8D9BF9C6304351F12DE8E23 /* 📦 Copy Pods Resources */, ); buildRules = ( ); @@ -126,17 +125,16 @@ D50BE3F41C9FE8870000A34C = { CreatedOnToolsVersion = 7.2.1; DevelopmentTeam = XVAH95CHDC; - LastSwiftMigration = 0800; + LastSwiftMigration = 1310; ProvisioningStyle = Manual; }; }; }; buildConfigurationList = D50BE3F01C9FE8870000A34C /* Build configuration list for PBXProject "BarcodeScannerExample" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -179,21 +177,6 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - A8D9BF9C6304351F12DE8E23 /* 📦 Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "📦 Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BarcodeScannerExample/Pods-BarcodeScannerExample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; BDF82C3FF3E7C5A57E2534BE /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -406,7 +389,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = "5429b4c3-def8-4c81-a541-9333e6f69af9"; PROVISIONING_PROFILE_SPECIFIER = "Wildcard Development"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -428,7 +411,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Example/BarcodeScannerExample/BarcodeScannerExample/AppDelegate.swift b/Example/BarcodeScannerExample/BarcodeScannerExample/AppDelegate.swift index 9614d91..f258a44 100644 --- a/Example/BarcodeScannerExample/BarcodeScannerExample/AppDelegate.swift +++ b/Example/BarcodeScannerExample/BarcodeScannerExample/AppDelegate.swift @@ -5,7 +5,7 @@ import BarcodeScanner class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } } diff --git a/Sources/Controllers/BarcodeScannerViewController.swift b/Sources/Controllers/BarcodeScannerViewController.swift index 0a166a0..5e9c1db 100644 --- a/Sources/Controllers/BarcodeScannerViewController.swift +++ b/Sources/Controllers/BarcodeScannerViewController.swift @@ -31,6 +31,7 @@ import AVFoundation - Unauthorized mode - Not found error message */ +@objcMembers open class BarcodeScannerViewController: UIViewController { public static var footerHeight: CGFloat = 75 @objc public var hideFooterView = false diff --git a/Sources/Controllers/CameraViewController.swift b/Sources/Controllers/CameraViewController.swift index f5a722d..814201c 100644 --- a/Sources/Controllers/CameraViewController.swift +++ b/Sources/Controllers/CameraViewController.swift @@ -2,18 +2,17 @@ import UIKit import AVFoundation /// Delegate to handle camera setup and video capturing. -protocol CameraViewControllerDelegate: AnyObject { +@objc protocol CameraViewControllerDelegate: AnyObject { func cameraViewControllerDidSetupCaptureSession(_ controller: CameraViewController) func cameraViewControllerDidFailToSetupCaptureSession(_ controller: CameraViewController) func cameraViewController(_ controller: CameraViewController, didReceiveError error: Error) func cameraViewControllerDidTapSettingsButton(_ controller: CameraViewController) - func cameraViewController( - _ controller: CameraViewController, - didOutput metadataObjects: [AVMetadataObject] + func cameraViewController(_ controller: CameraViewController, didOutput metadataObjects: [AVMetadataObject] ) } /// View controller responsible for camera controls and video capturing. +@objcMembers public final class CameraViewController: UIViewController { weak var delegate: CameraViewControllerDelegate? @@ -380,7 +379,7 @@ private extension CameraViewController { videoPreviewLayer.frame = view.layer.bounds if let connection = videoPreviewLayer.connection, connection.isVideoOrientationSupported { - switch UIApplication.shared.statusBarOrientation { + switch UIApplication.interfaceOrientation { case .portrait: connection.videoOrientation = .portrait case .landscapeRight: @@ -440,3 +439,16 @@ extension CameraViewController: AVCaptureMetadataOutputObjectsDelegate { delegate?.cameraViewController(self, didOutput: metadataObjects) } } + +// MARK: - Private + +private extension UIApplication { + + static var interfaceOrientation: UIInterfaceOrientation? { + if #available(iOS 13.0, *) { + return UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.windowScene?.interfaceOrientation + } else { + return UIApplication.shared.statusBarOrientation + } + } +} diff --git a/Sources/Controllers/HeaderViewController.swift b/Sources/Controllers/HeaderViewController.swift index 8eb1c9e..4ec10c8 100644 --- a/Sources/Controllers/HeaderViewController.swift +++ b/Sources/Controllers/HeaderViewController.swift @@ -1,12 +1,13 @@ import UIKit /// Delegate to handle touch event of the close button. -protocol HeaderViewControllerDelegate: AnyObject { +@objc protocol HeaderViewControllerDelegate: AnyObject { func headerViewControllerDidTapCloseButton(_ controller: HeaderViewController) } /// View controller with title label and close button. /// It will be added as a child view controller if `BarcodeScannerController` is being presented. +@objcMembers public final class HeaderViewController: UIViewController { weak var delegate: HeaderViewControllerDelegate? diff --git a/Sources/Controllers/MessageViewController.swift b/Sources/Controllers/MessageViewController.swift index 3fab7ab..ac9a0e2 100644 --- a/Sources/Controllers/MessageViewController.swift +++ b/Sources/Controllers/MessageViewController.swift @@ -1,6 +1,7 @@ import UIKit /// View controller used for showing info text and loading animation. +@objcMembers public final class MessageViewController: UIViewController { // Image tint color for all the states, except for `.notFound`. public var regularTintColor: UIColor = .black diff --git a/Sources/DataStructures/State.swift b/Sources/DataStructures/State.swift index 4c42de5..a7a2be1 100644 --- a/Sources/DataStructures/State.swift +++ b/Sources/DataStructures/State.swift @@ -11,7 +11,7 @@ enum State { } /// State message provider. -public struct StateMessageProvider { +public class StateMessageProvider: NSObject { public var scanningText = localizedString("INFO_DESCRIPTION_TEXT") public var processingText = localizedString("INFO_LOADING_TITLE") public var unathorizedText = localizedString("ASK_FOR_PERMISSION_TEXT")