From 05292f181474309775dd46d988215ee65e6e1920 Mon Sep 17 00:00:00 2001 From: Garett Date: Thu, 8 Oct 2020 13:45:47 -0600 Subject: [PATCH 1/5] Add SPM functionality --- .../contents.xcworkspacedata | 7 +++++ BarcodeScanner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ Package.swift | 26 ++++++++++++++++++ .../Images}/cameraRotate@3x.png | Bin {Images => Sources/Images}/flashOff@3x.png | Bin {Images => Sources/Images}/flashOn@3x.png | Bin {Images => Sources/Images}/info@3x.png | Bin 8 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata create mode 100644 Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Package.swift rename {Images => Sources/Images}/cameraRotate@3x.png (100%) rename {Images => Sources/Images}/flashOff@3x.png (100%) rename {Images => Sources/Images}/flashOn@3x.png (100%) rename {Images => Sources/Images}/info@3x.png (100%) diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/BarcodeScanner.xcodeproj/project.pbxproj b/BarcodeScanner.xcodeproj/project.pbxproj index 4b26f59..0482811 100644 --- a/BarcodeScanner.xcodeproj/project.pbxproj +++ b/BarcodeScanner.xcodeproj/project.pbxproj @@ -95,7 +95,6 @@ D5B2E8951C3A780C00C0327D = { isa = PBXGroup; children = ( - D50BE3E31C9FE7A80000A34C /* Images */, D5C629691C3A809D007F7B7C /* Sources */, D5C6295C1C3A800E007F7B7C /* BarcodeScanner */, D5B2E8A01C3A780C00C0327D /* Products */, @@ -121,6 +120,7 @@ D5C629691C3A809D007F7B7C /* Sources */ = { isa = PBXGroup; children = ( + D50BE3E31C9FE7A80000A34C /* Images */, D5CB3785201947D000B9319D /* Helpers */, D5CB37842019477900B9319D /* DataStructures */, D55281BD20167D9F00FF3CDD /* Extensions */, diff --git a/Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..c4ed36f --- /dev/null +++ b/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version:5.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "BarcodeScanner", + platforms: [.iOS(.v10)], + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "BarcodeScanner", + targets: ["BarcodeScanner"]), + ], + 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: "BarcodeScanner", + path: "Sources"), + ] +) diff --git a/Images/cameraRotate@3x.png b/Sources/Images/cameraRotate@3x.png similarity index 100% rename from Images/cameraRotate@3x.png rename to Sources/Images/cameraRotate@3x.png diff --git a/Images/flashOff@3x.png b/Sources/Images/flashOff@3x.png similarity index 100% rename from Images/flashOff@3x.png rename to Sources/Images/flashOff@3x.png diff --git a/Images/flashOn@3x.png b/Sources/Images/flashOn@3x.png similarity index 100% rename from Images/flashOn@3x.png rename to Sources/Images/flashOn@3x.png diff --git a/Images/info@3x.png b/Sources/Images/info@3x.png similarity index 100% rename from Images/info@3x.png rename to Sources/Images/info@3x.png From 1f67f8ed732a6e92ad14f8ffa1075d604dec9d88 Mon Sep 17 00:00:00 2001 From: Garett Date: Thu, 8 Oct 2020 15:12:06 -0600 Subject: [PATCH 2/5] Fix functions --- Package.swift | 3 ++- Sources/Helpers/Functions.swift | 14 ++------------ .../Localization}/de.lproj/Localizable.strings | 0 .../Localization}/en.lproj/Localizable.strings | 0 .../Localization}/fr.lproj/Localizable.strings | 0 .../Localization}/ja.lproj/Localizable.strings | 0 .../Localization}/pl-PL.lproj/Localizable.strings | 0 .../Localization}/tr.lproj/Localizable.strings | 0 8 files changed, 4 insertions(+), 13 deletions(-) rename {Localization => Sources/Localization}/de.lproj/Localizable.strings (100%) rename {Localization => Sources/Localization}/en.lproj/Localizable.strings (100%) rename {Localization => Sources/Localization}/fr.lproj/Localizable.strings (100%) rename {Localization => Sources/Localization}/ja.lproj/Localizable.strings (100%) rename {Localization => Sources/Localization}/pl-PL.lproj/Localizable.strings (100%) rename {Localization => Sources/Localization}/tr.lproj/Localizable.strings (100%) diff --git a/Package.swift b/Package.swift index c4ed36f..c2cb164 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,11 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.3 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "BarcodeScanner", + defaultLocalization: "en", platforms: [.iOS(.v10)], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. diff --git a/Sources/Helpers/Functions.swift b/Sources/Helpers/Functions.swift index f959382..af97fde 100644 --- a/Sources/Helpers/Functions.swift +++ b/Sources/Helpers/Functions.swift @@ -7,15 +7,9 @@ import AVFoundation - Returns: An image. */ func imageNamed(_ name: String) -> UIImage { - let cls = BarcodeScannerViewController.self - var bundle = Bundle(for: cls) let traitCollection = UITraitCollection(displayScale: 3) - if let resourceBundle = bundle.resourcePath.flatMap({ Bundle(path: $0 + "/BarcodeScanner.bundle") }) { - bundle = resourceBundle - } - - guard let image = UIImage(named: name, in: bundle, compatibleWith: traitCollection) else { + guard let image = UIImage(named: name, in: Bundle.module, compatibleWith: traitCollection) else { return UIImage() } @@ -28,11 +22,7 @@ func imageNamed(_ name: String) -> UIImage { - Returns: An image. */ func localizedString(_ key: String) -> String { - if let path = Bundle(for: BarcodeScannerViewController.self).resourcePath, - let resourceBundle = Bundle(path: path + "/Localization.bundle") { - return resourceBundle.localizedString(forKey: key, value: nil, table: "Localizable") - } - return key + NSLocalizedString(key, bundle: Bundle.module, comment: key) } /// Checks if the app is running in Simulator. diff --git a/Localization/de.lproj/Localizable.strings b/Sources/Localization/de.lproj/Localizable.strings similarity index 100% rename from Localization/de.lproj/Localizable.strings rename to Sources/Localization/de.lproj/Localizable.strings diff --git a/Localization/en.lproj/Localizable.strings b/Sources/Localization/en.lproj/Localizable.strings similarity index 100% rename from Localization/en.lproj/Localizable.strings rename to Sources/Localization/en.lproj/Localizable.strings diff --git a/Localization/fr.lproj/Localizable.strings b/Sources/Localization/fr.lproj/Localizable.strings similarity index 100% rename from Localization/fr.lproj/Localizable.strings rename to Sources/Localization/fr.lproj/Localizable.strings diff --git a/Localization/ja.lproj/Localizable.strings b/Sources/Localization/ja.lproj/Localizable.strings similarity index 100% rename from Localization/ja.lproj/Localizable.strings rename to Sources/Localization/ja.lproj/Localizable.strings diff --git a/Localization/pl-PL.lproj/Localizable.strings b/Sources/Localization/pl-PL.lproj/Localizable.strings similarity index 100% rename from Localization/pl-PL.lproj/Localizable.strings rename to Sources/Localization/pl-PL.lproj/Localizable.strings diff --git a/Localization/tr.lproj/Localizable.strings b/Sources/Localization/tr.lproj/Localizable.strings similarity index 100% rename from Localization/tr.lproj/Localizable.strings rename to Sources/Localization/tr.lproj/Localizable.strings From 3f0839fbb582e0987c95b47142f9172264fa0a7f Mon Sep 17 00:00:00 2001 From: Garett Date: Thu, 8 Oct 2020 15:23:57 -0600 Subject: [PATCH 3/5] Add assets --- Package.swift | 3 ++- Sources/Images/Images.xcassets/Contents.json | 6 +++++ .../cameraRotate.imageset/Contents.json | 21 ++++++++++++++++++ .../cameraRotate@3x.png | Bin .../flashOff.imageset/Contents.json | 21 ++++++++++++++++++ .../flashOff.imageset}/flashOff@3x.png | Bin .../flashOn.imageset/Contents.json | 21 ++++++++++++++++++ .../flashOn.imageset}/flashOn@3x.png | Bin .../info.imageset/Contents.json | 21 ++++++++++++++++++ .../info.imageset}/info@3x.png | Bin 10 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 Sources/Images/Images.xcassets/Contents.json create mode 100644 Sources/Images/Images.xcassets/cameraRotate.imageset/Contents.json rename Sources/Images/{ => Images.xcassets/cameraRotate.imageset}/cameraRotate@3x.png (100%) create mode 100644 Sources/Images/Images.xcassets/flashOff.imageset/Contents.json rename Sources/Images/{ => Images.xcassets/flashOff.imageset}/flashOff@3x.png (100%) create mode 100644 Sources/Images/Images.xcassets/flashOn.imageset/Contents.json rename Sources/Images/{ => Images.xcassets/flashOn.imageset}/flashOn@3x.png (100%) create mode 100644 Sources/Images/Images.xcassets/info.imageset/Contents.json rename Sources/Images/{ => Images.xcassets/info.imageset}/info@3x.png (100%) diff --git a/Package.swift b/Package.swift index c2cb164..17ceb0a 100644 --- a/Package.swift +++ b/Package.swift @@ -22,6 +22,7 @@ let package = Package( // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( name: "BarcodeScanner", - path: "Sources"), + path: "Sources", + resources: [.copy("Images/cameraRotate@3x.png")]), ] ) diff --git a/Sources/Images/Images.xcassets/Contents.json b/Sources/Images/Images.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/Images/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/Images/Images.xcassets/cameraRotate.imageset/Contents.json b/Sources/Images/Images.xcassets/cameraRotate.imageset/Contents.json new file mode 100644 index 0000000..dcae763 --- /dev/null +++ b/Sources/Images/Images.xcassets/cameraRotate.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "cameraRotate@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/Images/cameraRotate@3x.png b/Sources/Images/Images.xcassets/cameraRotate.imageset/cameraRotate@3x.png similarity index 100% rename from Sources/Images/cameraRotate@3x.png rename to Sources/Images/Images.xcassets/cameraRotate.imageset/cameraRotate@3x.png diff --git a/Sources/Images/Images.xcassets/flashOff.imageset/Contents.json b/Sources/Images/Images.xcassets/flashOff.imageset/Contents.json new file mode 100644 index 0000000..d663350 --- /dev/null +++ b/Sources/Images/Images.xcassets/flashOff.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "flashOff@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/Images/flashOff@3x.png b/Sources/Images/Images.xcassets/flashOff.imageset/flashOff@3x.png similarity index 100% rename from Sources/Images/flashOff@3x.png rename to Sources/Images/Images.xcassets/flashOff.imageset/flashOff@3x.png diff --git a/Sources/Images/Images.xcassets/flashOn.imageset/Contents.json b/Sources/Images/Images.xcassets/flashOn.imageset/Contents.json new file mode 100644 index 0000000..3c72d8a --- /dev/null +++ b/Sources/Images/Images.xcassets/flashOn.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "flashOn@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/Images/flashOn@3x.png b/Sources/Images/Images.xcassets/flashOn.imageset/flashOn@3x.png similarity index 100% rename from Sources/Images/flashOn@3x.png rename to Sources/Images/Images.xcassets/flashOn.imageset/flashOn@3x.png diff --git a/Sources/Images/Images.xcassets/info.imageset/Contents.json b/Sources/Images/Images.xcassets/info.imageset/Contents.json new file mode 100644 index 0000000..675e54e --- /dev/null +++ b/Sources/Images/Images.xcassets/info.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "info@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/Images/info@3x.png b/Sources/Images/Images.xcassets/info.imageset/info@3x.png similarity index 100% rename from Sources/Images/info@3x.png rename to Sources/Images/Images.xcassets/info.imageset/info@3x.png From 3c821fac3547ca4a265c04f75a69d956c7fc0a87 Mon Sep 17 00:00:00 2001 From: Garett Date: Thu, 8 Oct 2020 15:28:14 -0600 Subject: [PATCH 4/5] Project updates --- BarcodeScanner.xcodeproj/project.pbxproj | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/BarcodeScanner.xcodeproj/project.pbxproj b/BarcodeScanner.xcodeproj/project.pbxproj index 0482811..5b02f64 100644 --- a/BarcodeScanner.xcodeproj/project.pbxproj +++ b/BarcodeScanner.xcodeproj/project.pbxproj @@ -8,11 +8,8 @@ /* Begin PBXBuildFile section */ 2DBF9E0E1F169DEF006B5AA8 /* FocusViewType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DBF9E0D1F169DEF006B5AA8 /* FocusViewType.swift */; }; + CE8C0771252FBBAF007FF4A4 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE8C0770252FBBAF007FF4A4 /* Images.xcassets */; }; D504555F1FD8714700E46826 /* UIView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D504555E1FD8714700E46826 /* UIView+Extensions.swift */; }; - D50BE3E91C9FE7A80000A34C /* flashOff@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D50BE3E51C9FE7A80000A34C /* flashOff@3x.png */; }; - D50BE3EA1C9FE7A80000A34C /* flashOn@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D50BE3E61C9FE7A80000A34C /* flashOn@3x.png */; }; - D50BE3EB1C9FE7A80000A34C /* info@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D50BE3E71C9FE7A80000A34C /* info@3x.png */; }; - D5349DF8201E42D900CD53EA /* cameraRotate@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = D5349DF7201E42D900CD53EA /* cameraRotate@3x.png */; }; D55281B62016758F00FF3CDD /* HeaderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D55281B52016758F00FF3CDD /* HeaderViewController.swift */; }; D55281B8201675D500FF3CDD /* MessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D55281B7201675D500FF3CDD /* MessageViewController.swift */; }; D55281BA2016770800FF3CDD /* CameraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D55281B92016770800FF3CDD /* CameraViewController.swift */; }; @@ -28,11 +25,8 @@ /* Begin PBXFileReference section */ 2DBF9E0D1F169DEF006B5AA8 /* FocusViewType.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = FocusViewType.swift; sourceTree = ""; tabWidth = 2; }; + CE8C0770252FBBAF007FF4A4 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; D504555E1FD8714700E46826 /* UIView+Extensions.swift */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = "UIView+Extensions.swift"; sourceTree = ""; tabWidth = 2; }; - D50BE3E51C9FE7A80000A34C /* flashOff@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "flashOff@3x.png"; sourceTree = ""; }; - D50BE3E61C9FE7A80000A34C /* flashOn@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "flashOn@3x.png"; sourceTree = ""; }; - D50BE3E71C9FE7A80000A34C /* info@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "info@3x.png"; sourceTree = ""; }; - D5349DF7201E42D900CD53EA /* cameraRotate@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "cameraRotate@3x.png"; sourceTree = ""; }; D55281B52016758F00FF3CDD /* HeaderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderViewController.swift; sourceTree = ""; }; D55281B7201675D500FF3CDD /* MessageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewController.swift; sourceTree = ""; }; D55281B92016770800FF3CDD /* CameraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraViewController.swift; sourceTree = ""; }; @@ -62,10 +56,7 @@ D50BE3E31C9FE7A80000A34C /* Images */ = { isa = PBXGroup; children = ( - D5349DF7201E42D900CD53EA /* cameraRotate@3x.png */, - D50BE3E51C9FE7A80000A34C /* flashOff@3x.png */, - D50BE3E61C9FE7A80000A34C /* flashOn@3x.png */, - D50BE3E71C9FE7A80000A34C /* info@3x.png */, + CE8C0770252FBBAF007FF4A4 /* Images.xcassets */, ); path = Images; sourceTree = ""; @@ -218,10 +209,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - D50BE3E91C9FE7A80000A34C /* flashOff@3x.png in Resources */, - D5349DF8201E42D900CD53EA /* cameraRotate@3x.png in Resources */, - D50BE3EB1C9FE7A80000A34C /* info@3x.png in Resources */, - D50BE3EA1C9FE7A80000A34C /* flashOn@3x.png in Resources */, + CE8C0771252FBBAF007FF4A4 /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 0053a59528a31b87c80cdbaa47396ed3de7de82c Mon Sep 17 00:00:00 2001 From: Garett Date: Thu, 8 Oct 2020 15:36:25 -0600 Subject: [PATCH 5/5] Add new localizations --- .../Localization}/nl.lproj/Localizable.strings | 0 .../Localization}/pt-BR.lproj/Localizable.strings | 0 .../Localization}/ru.lproj/Localizable.strings | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {Localization => Sources/Localization}/nl.lproj/Localizable.strings (100%) rename {Localization => Sources/Localization}/pt-BR.lproj/Localizable.strings (100%) rename {Localization => Sources/Localization}/ru.lproj/Localizable.strings (100%) diff --git a/Localization/nl.lproj/Localizable.strings b/Sources/Localization/nl.lproj/Localizable.strings similarity index 100% rename from Localization/nl.lproj/Localizable.strings rename to Sources/Localization/nl.lproj/Localizable.strings diff --git a/Localization/pt-BR.lproj/Localizable.strings b/Sources/Localization/pt-BR.lproj/Localizable.strings similarity index 100% rename from Localization/pt-BR.lproj/Localizable.strings rename to Sources/Localization/pt-BR.lproj/Localizable.strings diff --git a/Localization/ru.lproj/Localizable.strings b/Sources/Localization/ru.lproj/Localizable.strings similarity index 100% rename from Localization/ru.lproj/Localizable.strings rename to Sources/Localization/ru.lproj/Localizable.strings