From fb9e7765c4975344d4033ffb1e233c4b1f05bf61 Mon Sep 17 00:00:00 2001 From: Alena Belyaeva Date: Thu, 3 Dec 2020 19:19:26 +0300 Subject: [PATCH 1/6] add package manifest --- .gitignore | 1 + Utils/.gitignore | 5 +++++ Utils/Package.resolved | 16 ++++++++++++++++ Utils/Package.swift | 39 +++++++++++++++++++++++++++++++++++++++ Utils/README.md | 3 +++ 5 files changed, 64 insertions(+) create mode 100644 Utils/.gitignore create mode 100644 Utils/Package.resolved create mode 100644 Utils/Package.swift create mode 100644 Utils/README.md diff --git a/.gitignore b/.gitignore index bfaa922..b187b54 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ Utils/fastlane/Provisioning Utils/fastlane/Build Utils/fastlane/report.xml Utils/buildData +Utils/.swiftpm .DS_Store # Bundler diff --git a/Utils/.gitignore b/Utils/.gitignore new file mode 100644 index 0000000..95c4320 --- /dev/null +++ b/Utils/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ diff --git a/Utils/Package.resolved b/Utils/Package.resolved new file mode 100644 index 0000000..85c6b6f --- /dev/null +++ b/Utils/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "CryptoSwift", + "repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift", + "state": { + "branch": null, + "revision": "39f08ac5269361a50c08ce1e2f41989bfc4b1ec8", + "version": "1.3.1" + } + } + ] + }, + "version": 1 +} diff --git a/Utils/Package.swift b/Utils/Package.swift new file mode 100644 index 0000000..22c8577 --- /dev/null +++ b/Utils/Package.swift @@ -0,0 +1,39 @@ +// 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: "Utils", + platforms: [.iOS(.v11)], + products: [ + .library( + name: "Utils", + targets: ["Utils"]), + ], + dependencies: [ + .package( + name: "CryptoSwift", + url: "https://github.com/krzyzanowskim/CryptoSwift", + .exact("1.3.1") + ) + ], + targets: [ + .target( + name: "Utils", + dependencies: ["CryptoSwift"], + path: "Utils", + exclude: [ + "Info.plist" + ] + ), + .testTarget( + name: "UtilsTests", + dependencies: ["Utils"], + path: "UtilsTests", + exclude: [ + "Info.plist" + ] + ) + ] +) diff --git a/Utils/README.md b/Utils/README.md new file mode 100644 index 0000000..4e20db1 --- /dev/null +++ b/Utils/README.md @@ -0,0 +1,3 @@ +# Utils + +A description of this package. From cef539aa620bea220ca061c452beb8129a410023 Mon Sep 17 00:00:00 2001 From: Alena Belyaeva Date: Thu, 3 Dec 2020 19:57:40 +0300 Subject: [PATCH 2/6] spm support for all utils for ios added --- Utils/Package.resolved | 9 +++++++++ Utils/Package.swift | 11 ++++++++--- Utils/Utils/BrightSide/BrightSide.swift | 1 + Utils/Utils/LoadingView/LoadingView.swift | 1 + Utils/Utils/LocalStorage/LocalStorage.swift | 3 +++ Utils/Utils/OTPField/DigitFieldStyle.swift | 2 ++ Utils/Utils/OTPField/OTPFieldStyle.swift | 2 ++ Utils/Utils/SettingsRouter/SettingsRouter.swift | 1 + Utils/Utils/UIDevice/UIDevice.swift | 1 + Utils/Utils/UIImage/UIImage+badgedImage.swift | 1 + .../UIDevice+feedbackType.swift | 3 +++ .../UIDevice+hasHapticFeedback.swift | 2 ++ .../UIDevice+hasTapticEngine.swift | 2 ++ .../VibrationFeedbackManager.swift | 2 ++ 14 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Utils/Package.resolved b/Utils/Package.resolved index 85c6b6f..d2ef343 100644 --- a/Utils/Package.resolved +++ b/Utils/Package.resolved @@ -9,6 +9,15 @@ "revision": "39f08ac5269361a50c08ce1e2f41989bfc4b1ec8", "version": "1.3.1" } + }, + { + "package": "Device", + "repositoryURL": "https://github.com/Alelenka/Device", + "state": { + "branch": "spm-support", + "revision": "df290adc142a10ef73a9b62e9f03e54d1f2f62ee", + "version": null + } } ] }, diff --git a/Utils/Package.swift b/Utils/Package.swift index 22c8577..85c7524 100644 --- a/Utils/Package.swift +++ b/Utils/Package.swift @@ -16,12 +16,17 @@ let package = Package( name: "CryptoSwift", url: "https://github.com/krzyzanowskim/CryptoSwift", .exact("1.3.1") - ) - ], + ), + .package( + name: "Device", + url: "https://github.com/Alelenka/Device", + .branch("spm-support") + ), + ], targets: [ .target( name: "Utils", - dependencies: ["CryptoSwift"], + dependencies: ["CryptoSwift", "Device"], path: "Utils", exclude: [ "Info.plist" diff --git a/Utils/Utils/BrightSide/BrightSide.swift b/Utils/Utils/BrightSide/BrightSide.swift index f5effe7..368910d 100644 --- a/Utils/Utils/BrightSide/BrightSide.swift +++ b/Utils/Utils/BrightSide/BrightSide.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit public final class BrightSide { diff --git a/Utils/Utils/LoadingView/LoadingView.swift b/Utils/Utils/LoadingView/LoadingView.swift index ffc7472..9fd206a 100644 --- a/Utils/Utils/LoadingView/LoadingView.swift +++ b/Utils/Utils/LoadingView/LoadingView.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit public protocol LoadingView: UIView { func setNeedAnimating(_ needAnimating: Bool) diff --git a/Utils/Utils/LocalStorage/LocalStorage.swift b/Utils/Utils/LocalStorage/LocalStorage.swift index d130445..bf3c55e 100644 --- a/Utils/Utils/LocalStorage/LocalStorage.swift +++ b/Utils/Utils/LocalStorage/LocalStorage.swift @@ -6,6 +6,9 @@ // Copyright © 2019 Surf. All rights reserved. // +import Foundation +import UIKit + /// Local storage based on filemanager uses cache directory final public class LocalStorage { diff --git a/Utils/Utils/OTPField/DigitFieldStyle.swift b/Utils/Utils/OTPField/DigitFieldStyle.swift index f1c4127..e799470 100644 --- a/Utils/Utils/OTPField/DigitFieldStyle.swift +++ b/Utils/Utils/OTPField/DigitFieldStyle.swift @@ -6,6 +6,8 @@ // Copyright © 2019 Surf. All rights reserved. // +import UIKit + public struct DigitFieldStyle { public let font: UIFont public let activeTextColor: UIColor diff --git a/Utils/Utils/OTPField/OTPFieldStyle.swift b/Utils/Utils/OTPField/OTPFieldStyle.swift index f8be680..322085c 100644 --- a/Utils/Utils/OTPField/OTPFieldStyle.swift +++ b/Utils/Utils/OTPField/OTPFieldStyle.swift @@ -6,6 +6,8 @@ // Copyright © 2019 Surf. All rights reserved. // +import UIKit + public struct OTPFieldStyle { public let digitStyle: DigitFieldStyle public let errorTextColor: UIColor diff --git a/Utils/Utils/SettingsRouter/SettingsRouter.swift b/Utils/Utils/SettingsRouter/SettingsRouter.swift index 4ee57a3..486d129 100644 --- a/Utils/Utils/SettingsRouter/SettingsRouter.swift +++ b/Utils/Utils/SettingsRouter/SettingsRouter.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit /// Utils for opening various settings screens from the application public final class SettingsRouter { diff --git a/Utils/Utils/UIDevice/UIDevice.swift b/Utils/Utils/UIDevice/UIDevice.swift index d6243ba..ccacdad 100644 --- a/Utils/Utils/UIDevice/UIDevice.swift +++ b/Utils/Utils/UIDevice/UIDevice.swift @@ -7,6 +7,7 @@ // import Device +import UIKit public extension UIDevice { diff --git a/Utils/Utils/UIImage/UIImage+badgedImage.swift b/Utils/Utils/UIImage/UIImage+badgedImage.swift index 2ef3fed..1ca130a 100644 --- a/Utils/Utils/UIImage/UIImage+badgedImage.swift +++ b/Utils/Utils/UIImage/UIImage+badgedImage.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit public extension UIImage { diff --git a/Utils/Utils/VibrationFeedbackManager/UIDevice+feedbackType.swift b/Utils/Utils/VibrationFeedbackManager/UIDevice+feedbackType.swift index 2fbec47..c18b15a 100644 --- a/Utils/Utils/VibrationFeedbackManager/UIDevice+feedbackType.swift +++ b/Utils/Utils/VibrationFeedbackManager/UIDevice+feedbackType.swift @@ -6,6 +6,9 @@ // Copyright © 2018 Surf. All rights reserved. // +import Foundation +import UIKit + extension UIDevice { enum FeedbackType: Int { case base = 0 diff --git a/Utils/Utils/VibrationFeedbackManager/UIDevice+hasHapticFeedback.swift b/Utils/Utils/VibrationFeedbackManager/UIDevice+hasHapticFeedback.swift index aa56995..f0d9410 100644 --- a/Utils/Utils/VibrationFeedbackManager/UIDevice+hasHapticFeedback.swift +++ b/Utils/Utils/VibrationFeedbackManager/UIDevice+hasHapticFeedback.swift @@ -6,6 +6,8 @@ // Copyright © 2018 Surf. All rights reserved. // +import UIKit + extension UIDevice { // haptic feedback support guarantees that device supports taptic engine too. var hasHapticFeedback: Bool { diff --git a/Utils/Utils/VibrationFeedbackManager/UIDevice+hasTapticEngine.swift b/Utils/Utils/VibrationFeedbackManager/UIDevice+hasTapticEngine.swift index 846dfe3..2bd3184 100644 --- a/Utils/Utils/VibrationFeedbackManager/UIDevice+hasTapticEngine.swift +++ b/Utils/Utils/VibrationFeedbackManager/UIDevice+hasTapticEngine.swift @@ -6,6 +6,8 @@ // Copyright © 2018 Surf. All rights reserved. // +import UIKit + extension UIDevice { var hasTapticEngine: Bool { return feedbackType == .taptic || hasHapticFeedback diff --git a/Utils/Utils/VibrationFeedbackManager/VibrationFeedbackManager.swift b/Utils/Utils/VibrationFeedbackManager/VibrationFeedbackManager.swift index c2388da..fc44980 100644 --- a/Utils/Utils/VibrationFeedbackManager/VibrationFeedbackManager.swift +++ b/Utils/Utils/VibrationFeedbackManager/VibrationFeedbackManager.swift @@ -7,6 +7,8 @@ // import AudioToolbox +import Foundation +import UIKit /** * From 12512187b46b0a593506369ffd8b4cba001da187 Mon Sep 17 00:00:00 2001 From: Alena Belyaeva Date: Fri, 4 Dec 2020 12:16:00 +0300 Subject: [PATCH 3/6] podfile to root directory --- .gitignore | 2 +- Utils/Package.resolved => Package.resolved | 0 Utils/Package.swift => Package.swift | 4 ++-- Utils/README.md | 3 --- 4 files changed, 3 insertions(+), 6 deletions(-) rename Utils/Package.resolved => Package.resolved (100%) rename Utils/Package.swift => Package.swift (93%) delete mode 100644 Utils/README.md diff --git a/.gitignore b/.gitignore index b187b54..d979369 100644 --- a/.gitignore +++ b/.gitignore @@ -71,7 +71,7 @@ Utils/fastlane/Provisioning Utils/fastlane/Build Utils/fastlane/report.xml Utils/buildData -Utils/.swiftpm +.swiftpm .DS_Store # Bundler diff --git a/Utils/Package.resolved b/Package.resolved similarity index 100% rename from Utils/Package.resolved rename to Package.resolved diff --git a/Utils/Package.swift b/Package.swift similarity index 93% rename from Utils/Package.swift rename to Package.swift index 85c7524..27ce0f8 100644 --- a/Utils/Package.swift +++ b/Package.swift @@ -27,7 +27,7 @@ let package = Package( .target( name: "Utils", dependencies: ["CryptoSwift", "Device"], - path: "Utils", + path: "Utils/Utils", exclude: [ "Info.plist" ] @@ -35,7 +35,7 @@ let package = Package( .testTarget( name: "UtilsTests", dependencies: ["Utils"], - path: "UtilsTests", + path: "Utils/UtilsTests", exclude: [ "Info.plist" ] diff --git a/Utils/README.md b/Utils/README.md deleted file mode 100644 index 4e20db1..0000000 --- a/Utils/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Utils - -A description of this package. From 94bc620bb1c85cb1b12d9756764a6739775cf2dc Mon Sep 17 00:00:00 2001 From: Alena Belyaeva Date: Wed, 9 Dec 2020 17:27:54 +0300 Subject: [PATCH 4/6] add swift build command to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b7c07c7..ea548e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ jobs: - cd Utils - make init - xcodebuild test -scheme Utils -workspace Utils.xcworkspace/ -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO -enableCodeCoverage YES -destination 'platform=iOS Simulator,name=iPhone 8,OS=12.2' | xcpretty -c + - swift build -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios12.1-simulator" -Xswiftc "-lswiftUIKit" - stage: Pod Lib Lint name: Pod Lib Lint script: From b78b1af693be2dd54caabc2cca15dc855075ad8b Mon Sep 17 00:00:00 2001 From: Alena Belyaeva Date: Thu, 17 Dec 2020 14:40:24 +0300 Subject: [PATCH 5/6] up pudspec --- SurfUtils.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SurfUtils.podspec b/SurfUtils.podspec index 0d1f29f..b501462 100644 --- a/SurfUtils.podspec +++ b/SurfUtils.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SurfUtils" - s.version = "11.0.0" + s.version = "11.1.0" s.summary = "Contains a set of utils in subspecs" s.description = <<-DESC Contains: From eb8cba75724e4e6462f74f20142c0a5867ccb1b4 Mon Sep 17 00:00:00 2001 From: Vadim Tikhonov Date: Mon, 5 Apr 2021 18:38:56 +0900 Subject: [PATCH 6/6] Load View with Bundle --- Utils/Utils/UIView/UIView+XibSetup.swift | 26 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Utils/Utils/UIView/UIView+XibSetup.swift b/Utils/Utils/UIView/UIView+XibSetup.swift index 65b80fb..9c509c8 100644 --- a/Utils/Utils/UIView/UIView+XibSetup.swift +++ b/Utils/Utils/UIView/UIView+XibSetup.swift @@ -9,15 +9,14 @@ import UIKit public extension UIView { - func xibSetup() { - let view = loadFromNib() + func xibSetup(bundle: Bundle) { + let view = loadFromNib(bundle: bundle) addSubview(view) stretch(view: view) } - func loadFromNib() -> T { + func loadFromNib(bundle: Bundle) -> T { let selfType = type(of: self) - let bundle = Bundle(for: selfType) let nibName = String(describing: selfType) let nib = UINib(nibName: nibName, bundle: bundle) @@ -28,8 +27,7 @@ public extension UIView { return view } - static func loadFromNib() -> T { - let bundle = Bundle(for: self) + static func loadFromNib(bundle: Bundle) -> T { let nibName = String(describing: self) let nib = UINib(nibName: nibName, bundle: bundle) @@ -40,6 +38,22 @@ public extension UIView { return view } + func xibSetup() { + let view = loadFromNib() + addSubview(view) + stretch(view: view) + } + + func loadFromNib() -> T { + let bundle = Bundle(for: type(of: self)) + return loadFromNib(bundle: bundle) + } + + static func loadFromNib() -> T { + let bundle = Bundle(for: self) + return loadFromNib(bundle: bundle) + } + func stretch(view: UIView) { view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([