Skip to content

Commit 7e7f1ea

Browse files
authored
Fix Swift 4.1 crash (#31)
* Fix Swift 4.1 crash * Version Bump * Update .podspec. * Update Code to handle multiple versions of swift
1 parent d38641c commit 7e7f1ea

File tree

10 files changed

+42
-8
lines changed

10 files changed

+42
-8
lines changed

Cely Demo/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0.2</string>
18+
<string>2.0.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
<key>LSRequiresIPhoneOS</key>

Cely.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Cely'
3-
s.version = '2.0.2'
3+
s.version = '2.0.3'
44
s.license = { :type => "MIT", :file => "LICENSE" }
55
s.summary = 'Cely’s goal is to add a login system into your app in under 30 seconds!'
66
s.homepage = 'https://chaione.com/'

Sources/Cely.swift

+6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ public struct Cely {
3030
/// - parameter withOptions: Dictionary of options to pass into cely upon setup. Please refer to `CelyOptions` to view all options.
3131
public static func setup<T: CelyUser, U>(with window: UIWindow?, forModel: T, requiredProperties:[U] = [], withOptions options: [CelyOptions : Any?]? = [:]) where T.Property == U {
3232

33+
#if swift(>=4.1)
34+
Cely.requiredProperties = requiredProperties.compactMap({"\($0.rawValue)"})
35+
#else
3336
Cely.requiredProperties = requiredProperties.flatMap({"\($0.rawValue)"})
37+
#endif
38+
39+
3440

3541
Cely.loginCompletionBlock = options?[.loginCompletionBlock] as? CelyLoginCompletion
3642
store = options?[.storage] as? CelyStorageProtocol ?? store

Sources/Info-tvOS.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0.2</string>
18+
<string>2.0.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

Sources/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0.2</string>
18+
<string>2.0.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

Tests/CelyStorageTests.swift

+18-2
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,37 @@ class StorageTests: XCTestCase {
125125
func testRemoveAllData() {
126126
testSavingData()
127127
var secureCount = store.secureStorage.count
128-
var storageCount = dummyData.flatMap({ dummy -> Any? in
128+
#if swift(>=4.1)
129+
var storageCount = dummyData.compactMap({ dummy -> Any? in
129130
guard !dummy.storeSecurely, !dummy.persisted else { return nil }
130131
return store.get(dummy.key)
131132
}).count
133+
#else
134+
var storageCount = dummyData.flatMap({ dummy -> Any? in
135+
guard !dummy.storeSecurely, !dummy.persisted else { return nil }
136+
return store.get(dummy.key)
137+
}).count
138+
#endif
139+
132140

133141
XCTAssert(secureCount == 5, "Did not add all entries inside of 'secureStorage'")
134142
XCTAssert(storageCount == 5, "Did not add all entries inside of 'storage'")
135143

136144
store.removeAllData()
137145

138146
secureCount = store.secureStorage.count
139-
storageCount = dummyData.flatMap({ dummy -> Any? in
147+
148+
#if swift(>=4.1)
149+
storageCount = dummyData.compactMap({ dummy -> Any? in
140150
guard !dummy.storeSecurely, !dummy.persisted else { return nil }
141151
return store.get(dummy.key)
142152
}).count
153+
#else
154+
storageCount = dummyData.flatMap({ dummy -> Any? in
155+
guard !dummy.storeSecurely, !dummy.persisted else { return nil }
156+
return store.get(dummy.key)
157+
}).count
158+
#endif
143159

144160
XCTAssert(secureCount == 0, "Did not remove all entries inside of 'secureStorage'")
145161
XCTAssert(storageCount == 1, "Did not remove all entries inside of 'storage'")

Tests/CelyTests.swift

+10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ class DummyStorage: CelyStorageProtocol {
4545
class CelyTests: XCTestCase {
4646
var _properties: [DummyUser.Property]!
4747
var raw_properties: [CelyProperty] {
48+
#if swift(>=4.1)
49+
return _properties.compactMap({"\($0.rawValue)"})
50+
#else
4851
return _properties.flatMap({"\($0.rawValue)"})
52+
#endif
53+
4954
}
5055
var triggeredNotification: String!
5156
override func setUp() {
@@ -84,7 +89,12 @@ class CelyTests: XCTestCase {
8489

8590

8691
func testSetup() {
92+
#if swift(>=4.1)
93+
let testRequiredProperties: [String] = _properties.compactMap({"\($0.rawValue)"})
94+
#else
8795
let testRequiredProperties: [String] = _properties.flatMap({"\($0.rawValue)"})
96+
#endif
97+
8898
XCTAssert(Cely.requiredProperties == testRequiredProperties, "Cely does not match the mock results")
8999
}
90100

Tests/Info-tvOS.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0.2</string>
18+
<string>2.0.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
<key>UIRequiredDeviceCapabilities</key>

Tests/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0.2</string>
18+
<string>2.0.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
</dict>

fastlane/Fastfile

+2
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ lane :version_bump do |options|
1010
version_number = get_version_number(xcodeproj: 'Cely.xcodeproj')
1111
puts version_number
1212
add_git_tag(tag: version_number)
13+
# Dont forget to update version on podspec
14+
# and run `pod trunk push Cely.podspec`
1315
end

0 commit comments

Comments
 (0)