Skip to content

Commit

Permalink
swift 4.2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
love4soul committed Sep 26, 2018
1 parent f4c4f88 commit d46d901
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
3 changes: 2 additions & 1 deletion CHICore.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
22 changes: 19 additions & 3 deletions CHICore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = Chili;
TargetAttributes = {
4935E3A81E9E21C600330982 = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion CHICore/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
4 changes: 2 additions & 2 deletions CHICore/Classes/BackgroundService/BackgroundService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions CHICore/Classes/Helpers/PKeyboardHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
8 changes: 4 additions & 4 deletions CHICore/Classes/Utils/String/String+Substring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int>) -> 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..<endIndex)
return String(self[startIndex..<endIndex])
}
}

0 comments on commit d46d901

Please sign in to comment.