diff --git a/Source/LBXScanViewController.swift b/Source/LBXScanViewController.swift index e0375de..75b5c79 100755 --- a/Source/LBXScanViewController.swift +++ b/Source/LBXScanViewController.swift @@ -72,6 +72,9 @@ open class LBXScanViewController: UIViewController { } @objc open func startScan() { + + if UIDevice.current.isSimulator { return } + if scanObj == nil { var cropRect = CGRect.zero if isOpenInterestRect { diff --git a/Source/UIDevice+Extensions.swift b/Source/UIDevice+Extensions.swift new file mode 100644 index 0000000..5118aba --- /dev/null +++ b/Source/UIDevice+Extensions.swift @@ -0,0 +1,19 @@ +// +// UIDevice+Extensions.swift +// swiftScan +// +// Created by Bertug Yilmaz (Dogus Teknoloji) on 5/20/21. +// Copyright © 2021 xialibing. All rights reserved. +// + +import UIKit + +extension UIDevice { + var isSimulator: Bool { + #if targetEnvironment(simulator) + return true + #else + return false + #endif + } +} diff --git a/swiftScan.xcodeproj/project.pbxproj b/swiftScan.xcodeproj/project.pbxproj index e1e6e4f..d6647f5 100755 --- a/swiftScan.xcodeproj/project.pbxproj +++ b/swiftScan.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 7D42B9B71C05EE9A0084D045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7D42B9B61C05EE9A0084D045 /* Assets.xcassets */; }; 7D42B9BA1C05EE9A0084D045 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7D42B9B81C05EE9A0084D045 /* LaunchScreen.storyboard */; }; 7DA82E091C19CE5E0028B5DB /* logo.JPG in Resources */ = {isa = PBXBuildFile; fileRef = 7DA82E081C19CE5E0028B5DB /* logo.JPG */; }; + CE3CAD792656BE61007EFD9D /* UIDevice+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3CAD782656BE61007EFD9D /* UIDevice+Extensions.swift */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -67,6 +68,7 @@ 7D46320C1C18683A00D70CF1 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; 7D46320D1C18683A00D70CF1 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = ""; }; 7DA82E081C19CE5E0028B5DB /* logo.JPG */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = logo.JPG; sourceTree = ""; }; + CE3CAD782656BE61007EFD9D /* UIDevice+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+Extensions.swift"; sourceTree = ""; }; D6DC96F61F6D0C0200E1CCEB /* SwiftScanner.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftScanner.h; sourceTree = ""; }; D6DC96F71F6D0C0200E1CCEB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ @@ -85,6 +87,7 @@ 488928DC1C1A7BE4005A8F83 /* Source */ = { isa = PBXGroup; children = ( + CE3CAE9B2656C2E7007EFD9D /* Extensions */, 48D3BBD01C70104100823F87 /* LBXPermissions.swift */, 488928DD1C1A7BE4005A8F83 /* LBXScanLineAnimation.swift */, 488928DE1C1A7BE4005A8F83 /* LBXScanNetAnimation.swift */, @@ -135,6 +138,14 @@ path = swiftScan; sourceTree = ""; }; + CE3CAE9B2656C2E7007EFD9D /* Extensions */ = { + isa = PBXGroup; + children = ( + CE3CAD782656BE61007EFD9D /* UIDevice+Extensions.swift */, + ); + name = Extensions; + sourceTree = ""; + }; D6DC96F51F6D0C0200E1CCEB /* SwiftScanner */ = { isa = PBXGroup; children = ( @@ -237,6 +248,7 @@ 73FF0B8F1CF545FE0083F169 /* ScanResultController.swift in Sources */, 488928E31C1A7BE4005A8F83 /* LBXScanLineAnimation.swift in Sources */, 48D3BBD11C70104100823F87 /* LBXPermissions.swift in Sources */, + CE3CAD792656BE61007EFD9D /* UIDevice+Extensions.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };