Skip to content

Commit dfa8c59

Browse files
authored
Fix swift 4 compiler crash (#23)
* Fix issues with Swift 4. * Fix image in README.md * update login gif * rename gif to update readme file * Update tests for Swift 4
1 parent 59a0765 commit dfa8c59

37 files changed

+45
-25
lines changed

Cely Demo/User.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct User: CelyUser {
4949
extension User {
5050

5151
static func save(_ value: Any, as property: Property) {
52-
property.save(value: value)
52+
property.save(value)
5353
}
5454

5555
static func save(_ data: [Property : Any]) {

Cely.xcodeproj/project.pbxproj

+29-11
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@
411411
children = (
412412
35CD64E51E60192300AF060B /* xcconfigs */,
413413
);
414-
path = Configuration;
414+
name = Configuration;
415+
path = Sources/Configuration;
415416
sourceTree = "<group>";
416417
};
417418
35CD64E51E60192300AF060B /* xcconfigs */ = {
@@ -424,7 +425,7 @@
424425
35CD65141E60192300AF060B /* watchOS */,
425426
);
426427
name = xcconfigs;
427-
path = Sources/xcconfigs;
428+
path = Sources/Configuration/xcconfigs;
428429
sourceTree = SOURCE_ROOT;
429430
};
430431
35CD64E71E60192300AF060B /* Base */ = {
@@ -691,12 +692,13 @@
691692
isa = PBXProject;
692693
attributes = {
693694
LastSwiftUpdateCheck = 0820;
694-
LastUpgradeCheck = 0820;
695+
LastUpgradeCheck = 0900;
695696
ORGANIZATIONNAME = ChaiOne;
696697
TargetAttributes = {
697698
1F28642A1E89578700EE8180 = {
698699
CreatedOnToolsVersion = 8.2.1;
699700
DevelopmentTeam = 7CX9JN6SPG;
701+
LastSwiftMigration = 0900;
700702
ProvisioningStyle = Automatic;
701703
SystemCapabilities = {
702704
com.apple.Keychain = {
@@ -706,7 +708,7 @@
706708
};
707709
3549BB201DA389CD00C63030 = {
708710
CreatedOnToolsVersion = 8.0;
709-
LastSwiftMigration = 0820;
711+
LastSwiftMigration = 0900;
710712
ProvisioningStyle = Automatic;
711713
};
712714
3549BB2D1DA389DB00C63030 = {
@@ -726,7 +728,7 @@
726728
};
727729
3549BB601DA38ADB00C63030 = {
728730
CreatedOnToolsVersion = 8.0;
729-
LastSwiftMigration = 0800;
731+
LastSwiftMigration = 0900;
730732
ProvisioningStyle = Manual;
731733
TestTargetID = 1F28642A1E89578700EE8180;
732734
};
@@ -1038,7 +1040,8 @@
10381040
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
10391041
PRODUCT_BUNDLE_IDENTIFIER = "com.chaione.Cely-Demo";
10401042
PRODUCT_NAME = "$(TARGET_NAME)";
1041-
SWIFT_VERSION = 3.0;
1043+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1044+
SWIFT_VERSION = 4.0;
10421045
};
10431046
name = Debug;
10441047
};
@@ -1054,7 +1057,8 @@
10541057
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
10551058
PRODUCT_BUNDLE_IDENTIFIER = "com.chaione.Cely-Demo";
10561059
PRODUCT_NAME = "$(TARGET_NAME)";
1057-
SWIFT_VERSION = 3.0;
1060+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1061+
SWIFT_VERSION = 4.0;
10581062
};
10591063
name = Release;
10601064
};
@@ -1068,7 +1072,9 @@
10681072
CLANG_CXX_LIBRARY = "libc++";
10691073
CLANG_ENABLE_MODULES = YES;
10701074
CLANG_ENABLE_OBJC_ARC = YES;
1075+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
10711076
CLANG_WARN_BOOL_CONVERSION = YES;
1077+
CLANG_WARN_COMMA = YES;
10721078
CLANG_WARN_CONSTANT_CONVERSION = YES;
10731079
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
10741080
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
@@ -1077,6 +1083,8 @@
10771083
CLANG_WARN_INFINITE_RECURSION = YES;
10781084
CLANG_WARN_INT_CONVERSION = YES;
10791085
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
1086+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
1087+
CLANG_WARN_STRICT_PROTOTYPES = YES;
10801088
CLANG_WARN_SUSPICIOUS_MOVE = YES;
10811089
CLANG_WARN_SUSPICIOUS_MOVES = YES;
10821090
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -1107,6 +1115,7 @@
11071115
SDKROOT = iphoneos;
11081116
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
11091117
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1118+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
11101119
TARGETED_DEVICE_FAMILY = "1,2";
11111120
VERSIONING_SYSTEM = "apple-generic";
11121121
VERSION_INFO_PREFIX = "";
@@ -1123,7 +1132,9 @@
11231132
CLANG_CXX_LIBRARY = "libc++";
11241133
CLANG_ENABLE_MODULES = YES;
11251134
CLANG_ENABLE_OBJC_ARC = YES;
1135+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
11261136
CLANG_WARN_BOOL_CONVERSION = YES;
1137+
CLANG_WARN_COMMA = YES;
11271138
CLANG_WARN_CONSTANT_CONVERSION = YES;
11281139
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
11291140
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
@@ -1132,6 +1143,8 @@
11321143
CLANG_WARN_INFINITE_RECURSION = YES;
11331144
CLANG_WARN_INT_CONVERSION = YES;
11341145
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
1146+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
1147+
CLANG_WARN_STRICT_PROTOTYPES = YES;
11351148
CLANG_WARN_SUSPICIOUS_MOVE = YES;
11361149
CLANG_WARN_SUSPICIOUS_MOVES = YES;
11371150
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -1154,6 +1167,7 @@
11541167
MTL_ENABLE_DEBUG_INFO = NO;
11551168
SDKROOT = iphoneos;
11561169
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1170+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
11571171
TARGETED_DEVICE_FAMILY = "1,2";
11581172
VALIDATE_PRODUCT = YES;
11591173
VERSIONING_SYSTEM = "apple-generic";
@@ -1180,7 +1194,8 @@
11801194
PRODUCT_NAME = Cely;
11811195
SKIP_INSTALL = YES;
11821196
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1183-
SWIFT_VERSION = 3.0;
1197+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1198+
SWIFT_VERSION = 4.0;
11841199
};
11851200
name = Debug;
11861201
};
@@ -1202,7 +1217,8 @@
12021217
PRODUCT_BUNDLE_IDENTIFIER = com.chaione.Cely.Cely;
12031218
PRODUCT_NAME = Cely;
12041219
SKIP_INSTALL = YES;
1205-
SWIFT_VERSION = 3.0;
1220+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1221+
SWIFT_VERSION = 4.0;
12061222
};
12071223
name = Release;
12081224
};
@@ -1366,7 +1382,8 @@
13661382
PRODUCT_BUNDLE_IDENTIFIER = com.chaione.Cely.CelyTests;
13671383
PRODUCT_NAME = "$(TARGET_NAME)";
13681384
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1369-
SWIFT_VERSION = 3.0;
1385+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1386+
SWIFT_VERSION = 4.0;
13701387
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Cely Demo.app/Cely Demo";
13711388
};
13721389
name = Debug;
@@ -1384,7 +1401,8 @@
13841401
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
13851402
PRODUCT_BUNDLE_IDENTIFIER = com.chaione.Cely.CelyTests;
13861403
PRODUCT_NAME = "$(TARGET_NAME)";
1387-
SWIFT_VERSION = 3.0;
1404+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1405+
SWIFT_VERSION = 4.0;
13881406
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Cely Demo.app/Cely Demo";
13891407
};
13901408
name = Release;

Cely.xcodeproj/xcshareddata/xcschemes/Cely-iOS.xcscheme

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES"
3031
codeCoverageEnabled = "YES">
3132
<Testables>
@@ -56,6 +57,7 @@
5657
buildConfiguration = "Debug"
5758
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5859
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
60+
language = ""
5961
launchStyle = "0"
6062
useCustomWorkingDirectory = "NO"
6163
ignoresPersistentStateOnLaunch = "NO"

Images/background_cely_login.gif

317 KB
Loading

Images/cely_login.gif

-155 KB
Binary file not shown.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Cely’s goal is to add a login system into your app in under 30 seconds!
2020
## Overview
2121
Cely's goal is to add a login system into your app in under 30 seconds!
2222

23-
<div style="text-align:center; background-color: #8B9DFC"><img style="height: 600px" src ="Images/cely_login.gif" /></div>
23+
<img style="height: 600px" src ="Images/background_cely_login.gif" />
2424

2525
### Background
2626
Whether you're building an app for a client or for a hackathon, building a login system, no matter how basic it is, can be very tedious and time-consuming. Cely's architecture has been battle tested on countless apps, and Cely guarantees you a fully functional login system in a fraction of the time. You can trust Cely is handling login credentials correctly as well since Cely is built on top of [Locksmith](https://github.com/matthewpalmer/Locksmith), swift's most popular Keychain wrapper.

Sources/Cely.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public struct Cely {
1414
fileprivate init() {}
1515
public typealias CelyLoginCompletion = (_ username: String, _ password: String) -> Void
1616
/// Properties that are needed inorder for user to stay logged in.
17-
internal static var requiredProperties: [CelyProperty] = []
17+
public static var requiredProperties: [CelyProperty] = []
1818

1919
/// A `Storage` instance
20-
internal static var store: CelyStorageProtocol = CelyStorage.sharedInstance
20+
public static var store: CelyStorageProtocol = CelyStorage.sharedInstance
2121

2222
/// A Completion Block that is expecting a `username:String` and a `password:String`
2323
public static var loginCompletionBlock: CelyLoginCompletion?
@@ -28,7 +28,7 @@ public struct Cely {
2828
/// - parameter forModel: The `Model` Cely will be storing.
2929
/// - parameter requiredProperties: `[CelyProperty]`: The properties that cely tests against to determine if a user is logged in.
3030
/// - parameter withOptions: Dictionary of options to pass into cely upon setup. Please refer to `CelyOptions` to view all options.
31-
public static func setup<T: CelyUser, U: RawRepresentable>(with window: UIWindow?, forModel: T, requiredProperties:[U] = [], withOptions options: [CelyOptions : Any?]? = [:]) where T.Property == U {
31+
public static func setup<T: CelyUser, U>(with window: UIWindow?, forModel: T, requiredProperties:[U] = [], withOptions options: [CelyOptions : Any?]? = [:]) where T.Property == U {
3232

3333
Cely.requiredProperties = requiredProperties.flatMap({"\($0.rawValue)"})
3434

Sources/CelyLoginViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CelyLoginViewController: UIViewController {
5757
NotificationCenter.default.removeObserver(self)
5858
}
5959

60-
func didPressLogin() {
60+
@objc func didPressLogin() {
6161
if let username = usernameField?.text, let password = passwordField?.text {
6262
Cely.loginCompletionBlock?(username, password)
6363
}
@@ -89,7 +89,7 @@ internal extension CelyLoginViewController {
8989
return (duration, endFrame, animationCurve)
9090
}
9191

92-
func keyboardNotification(notification: NSNotification) {
92+
@objc func keyboardNotification(notification: NSNotification) {
9393

9494
guard let (duration, endFrame, animationCurve) = convertNotification(notification: notification) else {
9595
return
File renamed without changes.

Sources/Locksmith.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public extension GenericPasswordSecureStorable {
271271
}
272272

273273
// dear god what have i done...
274-
public protocol GenericPasswordSecureStorableResultType: GenericPasswordSecureStorable, SecureStorableResultType, AccountBasedSecureStorableResultType, DescribableSecureStorableResultType, CommentableSecureStorableResultType, CreatorDesignatableSecureStorableResultType, IsInvisibleAssignableSecureStorableResultType {}
274+
public protocol GenericPasswordSecureStorableResultType: GenericPasswordSecureStorable, AccountBasedSecureStorableResultType, DescribableSecureStorableResultType, CommentableSecureStorableResultType, CreatorDesignatableSecureStorableResultType, IsInvisibleAssignableSecureStorableResultType {}
275275

276276
public extension GenericPasswordSecureStorableResultType {
277277
var service: String {

Tests/CelyLocksmithTests.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,16 @@ class LocksmithTests: XCTestCase {
288288
])
289289

290290
let cr = dict[String(kSecAttrCreator)] as! CFNumber
291-
XCTAssertEqual(cr as UInt, creator)
291+
XCTAssertEqual(cr as! UInt, creator)
292292

293293
let ty = dict[String(kSecAttrType)] as! CFNumber
294-
XCTAssertEqual(ty as UInt, type)
294+
XCTAssertEqual(ty as! UInt, type)
295295

296296
let inv = dict[String(kSecAttrIsInvisible)] as! CFBoolean
297-
XCTAssertEqual(inv as Bool, isInvisible)
297+
XCTAssertEqual(inv as! Bool, isInvisible)
298298

299299
let neg = dict[String(kSecAttrIsNegative)] as! CFBoolean
300-
XCTAssertEqual(neg as Bool, isNegative)
300+
XCTAssertEqual(neg as! Bool, isNegative)
301301

302302
let gen = dict[String(kSecAttrGeneric)]
303303
XCTAssertNil(gen)

Tests/CelyTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CelyTests: XCTestCase {
8484

8585

8686
func testSetup() {
87-
let testRequiredProperties = _properties.flatMap({"\($0.rawValue)"})
87+
let testRequiredProperties: [String] = _properties.flatMap({"\($0.rawValue)"})
8888
XCTAssert(Cely.requiredProperties == testRequiredProperties, "Cely does not match the mock results")
8989
}
9090

0 commit comments

Comments
 (0)