From d46d9011984902d5c5bd61caab84493b45e124f4 Mon Sep 17 00:00:00 2001 From: Igors Nemenonoks Date: Wed, 26 Sep 2018 16:52:08 +0300 Subject: [PATCH] swift 4.2 support --- CHICore.podspec | 3 ++- CHICore.xcodeproj/project.pbxproj | 22 ++++++++++++++++--- .../xcschemes/CHICore.xcscheme | 2 +- CHICore/AppDelegate.swift | 2 +- .../BackgroundService/BackgroundService.swift | 4 ++-- .../Classes/Helpers/PKeyboardHandlers.swift | 6 ++--- .../Utils/String/String+Substring.swift | 8 +++---- 7 files changed, 32 insertions(+), 15 deletions(-) diff --git a/CHICore.podspec b/CHICore.podspec index b5b925c..324fc2d 100644 --- a/CHICore.podspec +++ b/CHICore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'CHICore' -s.version = '0.2.1' +s.version = '0.3.0' s.summary = 'CHICore is a set of helpers and services for a project in CHili studio.' s.ios.deployment_target = '8.0' @@ -11,5 +11,6 @@ s.author = { 'Chili' => 'studio@chi.lv' } s.source = { :git => 'https://github.com/chili-ios/CHICore.git', :tag => s.version.to_s } s.source_files = 'CHICore/Classes/**/*.swift' +s.swift_version = '4.2' end diff --git a/CHICore.xcodeproj/project.pbxproj b/CHICore.xcodeproj/project.pbxproj index 1bd84ea..af59bfb 100644 --- a/CHICore.xcodeproj/project.pbxproj +++ b/CHICore.xcodeproj/project.pbxproj @@ -308,7 +308,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = Chili; TargetAttributes = { 4935E3A81E9E21C600330982 = { @@ -456,15 +456,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -506,15 +514,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -549,7 +565,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = lv.chi.CHICore; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -563,7 +579,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = lv.chi.CHICore; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/CHICore.xcodeproj/xcuserdata/igorsnemenonoks.xcuserdatad/xcschemes/CHICore.xcscheme b/CHICore.xcodeproj/xcuserdata/igorsnemenonoks.xcuserdatad/xcschemes/CHICore.xcscheme index 64fc220..060f1af 100644 --- a/CHICore.xcodeproj/xcuserdata/igorsnemenonoks.xcuserdatad/xcschemes/CHICore.xcscheme +++ b/CHICore.xcodeproj/xcuserdata/igorsnemenonoks.xcuserdatad/xcschemes/CHICore.xcscheme @@ -1,6 +1,6 @@ Bool { + private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/CHICore/Classes/BackgroundService/BackgroundService.swift b/CHICore/Classes/BackgroundService/BackgroundService.swift index b8167d0..bfb1c85 100644 --- a/CHICore/Classes/BackgroundService/BackgroundService.swift +++ b/CHICore/Classes/BackgroundService/BackgroundService.swift @@ -23,12 +23,12 @@ public class BackgroundService: PBackgroundService { private func registerForEvents() { NotificationCenter.default.addObserver(self, selector: #selector(BackgroundService.onAppBecomeActive), - name: NSNotification.Name.UIApplicationDidBecomeActive, + name: UIApplication.didBecomeActiveNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(BackgroundService.onAppDidEnterBackground), - name:NSNotification.Name.UIApplicationDidEnterBackground, + name: UIApplication.didEnterBackgroundNotification, object: nil) } diff --git a/CHICore/Classes/Helpers/PKeyboardHandlers.swift b/CHICore/Classes/Helpers/PKeyboardHandlers.swift index aac423f..23c75ec 100644 --- a/CHICore/Classes/Helpers/PKeyboardHandlers.swift +++ b/CHICore/Classes/Helpers/PKeyboardHandlers.swift @@ -16,18 +16,18 @@ public protocol PKeyboardObservable { extension PKeyboardObservable where Self : UIViewController { public func onKeyboardAppear(handler:@escaping ((CGRect) -> Void)) { _ = self.keyboardNotificationsObserver.addObserver( - forName: NSNotification.Name.UIKeyboardWillShow, + forName: UIResponder.keyboardWillShowNotification, object: nil, queue: OperationQueue.main ) { (notification) in - let value: NSValue = notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue + let value: NSValue = notification.userInfo![UIResponder.keyboardFrameEndUserInfoKey] as! NSValue let keyboardFrame: CGRect = value.cgRectValue handler(keyboardFrame) } } public func onKeyboardDissappear(handler:@escaping () -> Void) { - let notificationName = NSNotification.Name.UIKeyboardWillHide + let notificationName = UIResponder.keyboardWillHideNotification _ = self.keyboardNotificationsObserver.addObserver(forName: notificationName, object: nil, queue: OperationQueue.main) { _ in handler() } diff --git a/CHICore/Classes/Utils/String/String+Substring.swift b/CHICore/Classes/Utils/String/String+Substring.swift index 330e4aa..04106bf 100644 --- a/CHICore/Classes/Utils/String/String+Substring.swift +++ b/CHICore/Classes/Utils/String/String+Substring.swift @@ -15,14 +15,14 @@ extension String { func substring(from: Int) -> String { let fromIndex = index(from: from) - return substring(from: fromIndex) + return String(self[fromIndex...]) } func substring(with range: Range) -> String { - let safeRange = Range(uncheckedBounds: (lower: self.characters.count < range.lowerBound ? self.characters.count : range.lowerBound, - upper: self.characters.count < range.upperBound ? self.characters.count : range.upperBound)) + let safeRange = Range(uncheckedBounds: (lower: self.count < range.lowerBound ? self.count : range.lowerBound, + upper: self.count < range.upperBound ? self.count : range.upperBound)) let startIndex = index(from: safeRange.lowerBound) let endIndex = index(from: safeRange.upperBound) - return substring(with: startIndex..