Skip to content

Commit a556b75

Browse files
alextallinitFabian
authored andcommitted
Update to Swift 4.2 (#34)
* Update to Swift 4.2 Signed-off-by: Alex Du Bois <[email protected]> * Update Readme file for swift 4.2 * update tests for swift 4.2 * update tests to swift 4.2 syntax * update package manager information to swift 4.2
1 parent 31a0a99 commit a556b75

File tree

7 files changed

+61
-58
lines changed

7 files changed

+61
-58
lines changed

.swift-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.2

Cely Demo/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414

1515
var window: UIWindow?
1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818

1919
Cely.setup(with: window!, forModel: User(), requiredProperties: [.token], withOptions: [
2020
.loginCompletionBlock: { (username: String, password: String) in

Cely.podspec

+18-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
Pod::Spec.new do |s|
2-
s.name = 'Cely'
3-
s.version = '2.0.3'
4-
s.license = { :type => "MIT", :file => "LICENSE" }
5-
s.summary = 'Cely’s goal is to add a login system into your app in under 30 seconds!'
6-
s.homepage = 'https://chaione.com/'
7-
s.social_media_url = 'https://twitter.com/initfabian'
8-
s.authors = { "Fabian Buentello" => "[email protected]" }
9-
s.source = { :git => "https://github.com/ChaiOne/Cely.git", :tag => s.version.to_s }
10-
s.platforms = { :ios => "9.0" }
11-
s.requires_arc = true
1+
Pod::Spec.new do |spec|
2+
spec.swift_version = '4.2'
3+
spec.name = 'Cely'
4+
spec.version = '2.1.0'
5+
spec.license = { :type => "MIT", :file => "LICENSE" }
6+
spec.summary = 'Cely’s goal is to add a login system into your app in under 30 seconds!'
7+
spec.homepage = 'https://github.com/initFabian/Cely'
8+
spec.social_media_url = 'https://twitter.com/initfabian'
9+
spec.authors = { "Fabian Buentello" => "[email protected]" }
10+
spec.source = { :git => "https://github.com/initFabian/Cely.git", :tag => spec.version.to_s }
11+
spec.platforms = { :ios => "10.3" }
12+
spec.requires_arc = true
1213

13-
s.default_subspec = "Core"
14-
s.subspec "Core" do |ss|
15-
ss.resources = 'Sources/Supporting Files/*.{storyboard,xib,xcassets,json,imageset,png}'
16-
ss.source_files = "Sources/*.swift"
17-
ss.framework = "Foundation"
18-
end
14+
spec.default_subspec = "Core"
15+
spec.subspec "Core" do |subspec|
16+
subspec.resources = 'Sources/Supporting Files/*.{storyboard,xib,xcassets,json,imageset,png}'
17+
subspec.source_files = "Sources/*.swift"
18+
subspec.framework = "Foundation"
19+
end
1920

2021
end

Cely.xcodeproj/project.pbxproj

+10-11
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@
728728
};
729729
3549BB601DA38ADB00C63030 = {
730730
CreatedOnToolsVersion = 8.0;
731-
LastSwiftMigration = 0900;
731+
LastSwiftMigration = 1010;
732732
ProvisioningStyle = Manual;
733733
TestTargetID = 1F28642A1E89578700EE8180;
734734
};
@@ -749,6 +749,7 @@
749749
developmentRegion = English;
750750
hasScannedForEncodings = 0;
751751
knownRegions = (
752+
English,
752753
en,
753754
Base,
754755
);
@@ -1041,7 +1042,7 @@
10411042
PRODUCT_BUNDLE_IDENTIFIER = "com.chaione.Cely-Demo";
10421043
PRODUCT_NAME = "$(TARGET_NAME)";
10431044
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1044-
SWIFT_VERSION = 4.0;
1045+
SWIFT_VERSION = 4.2;
10451046
};
10461047
name = Debug;
10471048
};
@@ -1058,7 +1059,7 @@
10581059
PRODUCT_BUNDLE_IDENTIFIER = "com.chaione.Cely-Demo";
10591060
PRODUCT_NAME = "$(TARGET_NAME)";
10601061
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1061-
SWIFT_VERSION = 4.0;
1062+
SWIFT_VERSION = 4.2;
10621063
};
10631064
name = Release;
10641065
};
@@ -1109,7 +1110,7 @@
11091110
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
11101111
GCC_WARN_UNUSED_FUNCTION = YES;
11111112
GCC_WARN_UNUSED_VARIABLE = YES;
1112-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
1113+
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
11131114
MTL_ENABLE_DEBUG_INFO = YES;
11141115
ONLY_ACTIVE_ARCH = YES;
11151116
SDKROOT = iphoneos;
@@ -1163,7 +1164,7 @@
11631164
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
11641165
GCC_WARN_UNUSED_FUNCTION = YES;
11651166
GCC_WARN_UNUSED_VARIABLE = YES;
1166-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
1167+
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
11671168
MTL_ENABLE_DEBUG_INFO = NO;
11681169
SDKROOT = iphoneos;
11691170
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -1195,7 +1196,7 @@
11951196
SKIP_INSTALL = YES;
11961197
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
11971198
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1198-
SWIFT_VERSION = 4.0;
1199+
SWIFT_VERSION = 4.2;
11991200
};
12001201
name = Debug;
12011202
};
@@ -1218,7 +1219,7 @@
12181219
PRODUCT_NAME = Cely;
12191220
SKIP_INSTALL = YES;
12201221
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1221-
SWIFT_VERSION = 4.0;
1222+
SWIFT_VERSION = 4.2;
12221223
};
12231224
name = Release;
12241225
};
@@ -1382,8 +1383,7 @@
13821383
PRODUCT_BUNDLE_IDENTIFIER = com.chaione.Cely.CelyTests;
13831384
PRODUCT_NAME = "$(TARGET_NAME)";
13841385
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1385-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1386-
SWIFT_VERSION = 4.0;
1386+
SWIFT_VERSION = 4.2;
13871387
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Cely Demo.app/Cely Demo";
13881388
};
13891389
name = Debug;
@@ -1401,8 +1401,7 @@
14011401
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
14021402
PRODUCT_BUNDLE_IDENTIFIER = com.chaione.Cely.CelyTests;
14031403
PRODUCT_NAME = "$(TARGET_NAME)";
1404-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1405-
SWIFT_VERSION = 4.0;
1404+
SWIFT_VERSION = 4.2;
14061405
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Cely Demo.app/Cely Demo";
14071406
};
14081407
name = Release;

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ source 'https://github.com/CocoaPods/Specs.git'
700700
platform :ios, '8.0'
701701
use_frameworks!
702702

703-
pod 'Cely', '~> 2.0'
703+
pod 'Cely', '~> 2.1'
704704
```
705705

706706
Then, run the following command:
@@ -723,7 +723,7 @@ $ brew install carthage
723723
To integrate Cely into your Xcode project using Carthage, specify it in your `Cartfile`:
724724

725725
```ogdl
726-
github "initFabian/Cely" ~> 2.0
726+
github "initFabian/Cely" ~> 2.1
727727
```
728728

729729
### Manually

Sources/CelyLoginViewController.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ internal extension CelyLoginViewController {
7373

7474
fileprivate func setUpKeyboardNotification() {
7575
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardNotification(notification:)),
76-
name: .UIKeyboardWillChangeFrame, object: nil)
76+
name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
7777
}
7878

79-
func convertNotification(notification: NSNotification) -> (duration: Double, endFrame: CGRect, animationCurve: UIViewAnimationOptions)? {
79+
func convertNotification(notification: NSNotification) -> (duration: Double, endFrame: CGRect, animationCurve: UIView.AnimationOptions)? {
8080

8181
guard let userInfo = notification.userInfo,
82-
let duration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue,
83-
let endFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue,
84-
let rawCurve = (notification.userInfo![UIKeyboardAnimationCurveUserInfoKey] as? NSNumber)?.uint32Value else { return nil }
82+
let duration = (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue,
83+
let endFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue,
84+
let rawCurve = (notification.userInfo![UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber)?.uint32Value else { return nil }
8585

8686
let rawAnimationCurve = rawCurve << 16
87-
let animationCurve = UIViewAnimationOptions(rawValue: UInt(rawAnimationCurve))
87+
let animationCurve = UIView.AnimationOptions(rawValue: UInt(rawAnimationCurve))
8888

8989
return (duration, endFrame, animationCurve)
9090
}

Tests/LoginViewControllerTests.swift

+23-20
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ class LoginViewControllerTests: XCTestCase {
3737
CelyWindowManager.manager.loginStyle = DummyStyles()
3838
loginVC = CelyLoginViewController()
3939

40-
loginVC.usernameField = UITextField()
40+
let usernameTextField = UITextField()
41+
let passwordTextField = UITextField()
42+
43+
loginVC.usernameField = usernameTextField
4144
loginVC.usernameField?.tag = 0
42-
loginVC.passwordField = UITextField()
45+
loginVC.passwordField = passwordTextField
4346
loginVC.passwordField?.tag = 1
4447
loginVC.textFields = [loginVC.usernameField!, loginVC.passwordField!]
4548
loginVC.viewDidLoad()
@@ -133,12 +136,12 @@ extension LoginViewControllerTests {
133136

134137
func testConvertNotification_Failure() {
135138
let fakeUserInfo: [AnyHashable : Any] = [
136-
UIKeyboardAnimationDurationUserInfoKey : "FORCE FAIL",
137-
UIKeyboardFrameEndUserInfoKey : NSValue(cgRect: .zero),
138-
UIKeyboardAnimationCurveUserInfoKey : NSNumber(value: 30)
139+
UIResponder.keyboardAnimationDurationUserInfoKey : "FORCE FAIL",
140+
UIResponder.keyboardFrameEndUserInfoKey : NSValue(cgRect: .zero),
141+
UIWindow.keyboardAnimationCurveUserInfoKey : NSNumber(value: 30)
139142
]
140143

141-
let fakeNotification = NSNotification(name: .UIKeyboardWillChangeFrame, object: nil, userInfo: fakeUserInfo)
144+
let fakeNotification = NSNotification(name: UIResponder.keyboardWillChangeFrameNotification, object: nil, userInfo: fakeUserInfo)
142145

143146
let converted = loginVC.convertNotification(notification: fakeNotification)
144147

@@ -148,12 +151,12 @@ extension LoginViewControllerTests {
148151
func testConvertNotification_Success() {
149152

150153
let fakeUserInfo: [AnyHashable : Any] = [
151-
UIKeyboardAnimationDurationUserInfoKey : NSNumber(value: 20),
152-
UIKeyboardFrameEndUserInfoKey : NSValue(cgRect: .zero),
153-
UIKeyboardAnimationCurveUserInfoKey : NSNumber(value: 30)
154+
UIResponder.keyboardAnimationDurationUserInfoKey : NSNumber(value: 20),
155+
UIResponder.keyboardFrameEndUserInfoKey : NSValue(cgRect: .zero),
156+
UIResponder.keyboardAnimationCurveUserInfoKey : NSNumber(value: 30)
154157
]
155158

156-
let fakeNotification = NSNotification(name: .UIKeyboardWillChangeFrame, object: nil, userInfo: fakeUserInfo)
159+
let fakeNotification = NSNotification(name: UIResponder.keyboardWillChangeFrameNotification, object: nil, userInfo: fakeUserInfo)
157160

158161
let converted = loginVC.convertNotification(notification: fakeNotification)
159162

@@ -163,8 +166,8 @@ extension LoginViewControllerTests {
163166
XCTAssertEqual(converted?.endFrame, .zero, "failed to set endFrame")
164167
XCTAssert(type(of: converted!.endFrame) == CGRect.self, "endFrame is not of type CGRect.")
165168

166-
XCTAssertEqual(converted?.animationCurve, UIViewAnimationOptions(rawValue: UInt(30) << 16), "failed to set duration")
167-
XCTAssert(type(of: converted!.animationCurve) == UIViewAnimationOptions.self, "animationCurve is not of type UIViewAnimationOptions.")
169+
XCTAssertEqual(converted?.animationCurve, UIView.AnimationOptions(rawValue: UInt(30) << 16), "failed to set duration")
170+
XCTAssert(type(of: converted!.animationCurve) == UIView.AnimationOptions.self, "animationCurve is not of type UIViewAnimationOptions.")
168171

169172
print(converted ?? "failed to convert")
170173
}
@@ -176,12 +179,12 @@ extension LoginViewControllerTests {
176179
loginVC.bottomLayoutConstraint.constant = 20
177180

178181
let fakeUserInfo: [AnyHashable : Any] = [
179-
UIKeyboardAnimationDurationUserInfoKey : NSNumber(value: 20),
180-
UIKeyboardFrameEndUserInfoKey : NSValue(cgRect: CGRect(x: 0, y: 200, width: 320, height: 500)),
181-
UIKeyboardAnimationCurveUserInfoKey : NSNumber(value: 30)
182+
UIResponder.keyboardAnimationDurationUserInfoKey : NSNumber(value: 20),
183+
UIResponder.keyboardFrameEndUserInfoKey : NSValue(cgRect: CGRect(x: 0, y: 200, width: 320, height: 500)),
184+
UIResponder.keyboardAnimationCurveUserInfoKey : NSNumber(value: 30)
182185
]
183186

184-
let fakeNotification = NSNotification(name: .UIKeyboardWillChangeFrame, object: nil, userInfo: fakeUserInfo)
187+
let fakeNotification = NSNotification(name: UIResponder.keyboardWillChangeFrameNotification, object: nil, userInfo: fakeUserInfo)
185188

186189
loginVC.keyboardNotification(notification: fakeNotification)
187190

@@ -198,12 +201,12 @@ extension LoginViewControllerTests {
198201
loginVC.bottomLayoutConstraint.constant = 20
199202

200203
let fakeUserInfo: [AnyHashable : Any] = [
201-
UIKeyboardAnimationDurationUserInfoKey : "FORCE FAIL",
202-
UIKeyboardFrameEndUserInfoKey : NSValue(cgRect: CGRect(x: 0, y: 200, width: 320, height: 500)),
203-
UIKeyboardAnimationCurveUserInfoKey : NSNumber(value: 30)
204+
UIResponder.keyboardAnimationDurationUserInfoKey : "FORCE FAIL",
205+
UIResponder.keyboardFrameEndUserInfoKey : NSValue(cgRect: CGRect(x: 0, y: 200, width: 320, height: 500)),
206+
UIResponder.keyboardAnimationCurveUserInfoKey : NSNumber(value: 30)
204207
]
205208

206-
let fakeNotification = NSNotification(name: .UIKeyboardWillChangeFrame, object: nil, userInfo: fakeUserInfo)
209+
let fakeNotification = NSNotification(name: UIResponder.keyboardWillChangeFrameNotification, object: nil, userInfo: fakeUserInfo)
207210

208211
loginVC.keyboardNotification(notification: fakeNotification)
209212

0 commit comments

Comments
 (0)