diff --git a/CardScan/Classes/API.swift b/CardScan/Classes/API.swift index cced392a..f9e071f9 100644 --- a/CardScan/Classes/API.swift +++ b/CardScan/Classes/API.swift @@ -103,7 +103,7 @@ public struct Api { } static func getSdkVersion() -> String? { - guard let bundle = BundleURL.bundle() else { + guard let bundle = CardScan.bundle() else { return nil } diff --git a/CardScan/Classes/BundleURL.swift b/CardScan/Classes/CardScan.swift similarity index 91% rename from CardScan/Classes/BundleURL.swift rename to CardScan/Classes/CardScan.swift index d5107fb2..65c4a778 100644 --- a/CardScan/Classes/BundleURL.swift +++ b/CardScan/Classes/CardScan.swift @@ -1,4 +1,13 @@ -public struct BundleURL { +// +// CardScan.swift +// CardScan +// +// Created by Jaime Park on 1/29/20. +// + +import Foundation + +public class CardScan { // If you change the bundle name make sure to set these before // initializing the library public static var bundleName = "CardScan" diff --git a/CardScan/Classes/FindFourOcr.swift b/CardScan/Classes/FindFourOcr.swift index 82554fb0..02d2b11d 100644 --- a/CardScan/Classes/FindFourOcr.swift +++ b/CardScan/Classes/FindFourOcr.swift @@ -88,7 +88,7 @@ struct FindFourOcr { static func initializeModels() { if FindFourOcr.recognizeModel == nil { - guard let fourRecognizeUrl = BundleURL.compiledModel(forResource: fourRecognizeResource, withExtension: fourRecognizeExtension) else { + guard let fourRecognizeUrl = CardScan.compiledModel(forResource: fourRecognizeResource, withExtension: fourRecognizeExtension) else { print("Could not find URL for FourRecognize") return } @@ -101,7 +101,7 @@ struct FindFourOcr { FindFourOcr.recognizeModel = recognizeModel } if FindFourOcr.detectModel == nil { - guard let findFourUrl = BundleURL.compiledModel(forResource: findFourResource, withExtension: findFourExtension) else { + guard let findFourUrl = CardScan.compiledModel(forResource: findFourResource, withExtension: findFourExtension) else { print("Could not find URL for FindFour") return } diff --git a/CardScan/Classes/ScanBaseViewController.swift b/CardScan/Classes/ScanBaseViewController.swift index ced26897..63909052 100644 --- a/CardScan/Classes/ScanBaseViewController.swift +++ b/CardScan/Classes/ScanBaseViewController.swift @@ -149,7 +149,7 @@ public protocol TestingImageDataSource: AnyObject { } @objc static public func cameraImage() -> UIImage? { - guard let bundle = BundleURL.bundle() else { + guard let bundle = CardScan.bundle() else { return nil } diff --git a/CardScan/Classes/ScanViewController.swift b/CardScan/Classes/ScanViewController.swift index 10a6736d..46a9b8ba 100644 --- a/CardScan/Classes/ScanViewController.swift +++ b/CardScan/Classes/ScanViewController.swift @@ -139,7 +139,7 @@ import UIKit // The forced unwrap here is intentional -- we expect this to crash // if someone uses it with an invalid bundle - let bundle = BundleURL.bundle()! + let bundle = CardScan.bundle()! let storyboard = UIStoryboard(name: "CardScan", bundle: bundle) let viewController = storyboard.instantiateViewController(withIdentifier: "scanCardViewController") as! ScanViewController diff --git a/Example/CardScan/AppDelegate.swift b/Example/CardScan/AppDelegate.swift index e9bafda9..a0a2489e 100644 --- a/Example/CardScan/AppDelegate.swift +++ b/Example/CardScan/AppDelegate.swift @@ -16,10 +16,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - let bundle = BundleURL.bundle() - BundleURL.cardScanBundle = bundle - BundleURL.bundleName = "" - BundleURL.extensionName = "" + let bundle = CardScan.bundle() + CardScan.cardScanBundle = bundle + CardScan.bundleName = "" + CardScan.extensionName = "" ScanViewController.configure() return true } diff --git a/Example/CardScan_ExampleTests/CardScan_BundleTests.swift b/Example/CardScan_ExampleTests/CardScan_BundleTests.swift index dc0afd40..6f927aa3 100644 --- a/Example/CardScan_ExampleTests/CardScan_BundleTests.swift +++ b/Example/CardScan_ExampleTests/CardScan_BundleTests.swift @@ -22,18 +22,18 @@ class CardScan_BundleTests: XCTestCase { } func testForResource() { - var findFourURl = BundleURL.compiledModel(forResource: "feefifofum", withExtension: "bin") + var findFourURl = CardScan.compiledModel(forResource: "feefifofum", withExtension: "bin") XCTAssert(findFourURl == nil) - findFourURl = BundleURL.compiledModel(forResource: "FindFour", withExtension: "mlmodelc") + findFourURl = CardScan.compiledModel(forResource: "FindFour", withExtension: "mlmodelc") XCTAssert(findFourURl != nil) } func testWithExtension() { - var findFourURl = BundleURL.compiledModel(forResource: "FindFour", withExtension: "fee") + var findFourURl = CardScan.compiledModel(forResource: "FindFour", withExtension: "fee") XCTAssert(findFourURl == nil) - findFourURl = BundleURL.compiledModel(forResource: "FindFour", withExtension: "mlmodelc") + findFourURl = CardScan.compiledModel(forResource: "FindFour", withExtension: "mlmodelc") XCTAssert(findFourURl != nil) } }