Skip to content

Commit c7c83f1

Browse files
authored
feat: Improve ParseVersion and SDK Initialization (#49)
* fix: improve threading support * improve installation * improve gets * try class func * move URLSession static methods to utility * add random delay to networking * improve mocker delay * swift multiple threads to 3 * add changelog * don't run windows latest test * use random delay by default when testing * lower random delay range * use larger delay range for threaded tests * nits * improve ParseVersion * fix tests for new ParseVersion * Fix migrating Keychain * fix failing tests * add tests * bump version to beta2 * nits * Update Playgrounds and Changelog * add documentation for throwing errors * run swiftLint on tvOS * update DocC * add delay to some network tests * don't lint markdown * fix docc warning
1 parent 1e2d713 commit c7c83f1

File tree

141 files changed

+1218
-865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+1218
-865
lines changed

Diff for: CHANGELOG.md

+19-22
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,37 @@
88
### 5.0.0
99
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.16.2...5.0.0), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.0.0/documentation/parseswift)
1010

11-
__New features__
12-
13-
* Adds the the ability to watch particular keys with LiveQueries. Requires Parse-Server 6.0.0 ([#47](https://github.com/netreconlab/Parse-Swift/pull/47)), thanks to [Corey Baker](https://github.com/cbaker6).
14-
15-
* (Breaking Change) Added a new ParseHealth.Status enum to support Parse Server.
16-
Developers can access the new status values (Status.initialized, Status.starting)
17-
using the ParseHealth.check callback or Combine methods. The new status values
18-
are not available for async/await and synchounous methods. Connecting to Parse
19-
Servers < 6.0.0, using async/await, or synchronous methods only returns
20-
Status.ok or throws an error
11+
__Breaking Changes__
12+
* ParseVersion now supports pre-release versions of the SDK ([#49](https://github.com/netreconlab/Parse-Swift/pull/49)), thanks to [Corey Baker](https://github.com/cbaker6).
13+
* Added a new ParseHealth.Status enum to support new feature in Parse Server 6.0.0.
14+
Developers can now receive intermediate status updates (Status.initialized, Status.starting)
15+
using the ParseHealth.check callback or Combine methods. Status.initialized and
16+
Status.starting will only show for async/await and synchronous methods if they are the
17+
last value reported from the server after maxConnectionAttempts. Connecting to Parse
18+
Servers < 6.0.0 only returns Status.ok or a ParseError
2119
([#43](https://github.com/netreconlab/Parse-Swift/pull/43)),
2220
thanks to [Corey Baker](https://github.com/cbaker6).
21+
* Add and update ParseError codes. unknownError has been renamed
22+
to otherCause. invalidImageData now has the correct error code of 150. webhookError has
23+
the correct error code of 143 ([#23](https://github.com/netreconlab/Parse-Swift/pull/23)),
24+
thanks to [Corey Baker](https://github.com/cbaker6).
25+
* Remove all deprecated code. Be sure to follow the suggestions of all
26+
deprecation warnings when building your app in Xcode before upgrading
27+
([#23](https://github.com/netreconlab/Parse-Swift/pull/23)), thanks
28+
to [Corey Baker](https://github.com/cbaker6).
2329

30+
__New features__
31+
* ParseVersion now supports pre-release versions of the SDK ([#49](https://github.com/netreconlab/Parse-Swift/pull/49)), thanks to [Corey Baker](https://github.com/cbaker6).
32+
* Adds the the ability to watch particular keys with LiveQueries. Requires Parse-Server 6.0.0 ([#48](https://github.com/netreconlab/Parse-Swift/pull/48)), thanks to [Corey Baker](https://github.com/cbaker6).
2433
* The Swift SDK can now properly handle HTTP Status codes 429 and 503 and will retry after the delay specified in the respective header ([#43](https://github.com/netreconlab/Parse-Swift/pull/43)), thanks to [Corey Baker](https://github.com/cbaker6).
25-
2634
* The max connection attempts for LiveQuery can now be changed when initializing the SDK ([#43](https://github.com/netreconlab/Parse-Swift/pull/43)), thanks to [Corey Baker](https://github.com/cbaker6).
2735

2836
__Fixes__
29-
3037
* Fixed issues that can cause cache misses when querying ([#46](https://github.com/netreconlab/Parse-Swift/pull/46)), thanks to [Corey Baker](https://github.com/cbaker6).
31-
3238
* Fixed a threading issue with .current objects that can cause apps to crash
3339
([#45](https://github.com/netreconlab/Parse-Swift/pull/45)), thanks
3440
to [Corey Baker](https://github.com/cbaker6).
3541

36-
* (Breaking Change) Add and update ParseError codes. unknownError has been renamed
37-
to otherCause. invalidImageData now has the error code of 150. webhookError has
38-
the error code of 143 ([#23](https://github.com/netreconlab/Parse-Swift/pull/23)),
39-
thanks to [Corey Baker](https://github.com/cbaker6).
40-
41-
* (Breaking Change) Remove deprecated code
42-
([#23](https://github.com/netreconlab/Parse-Swift/pull/23)), thanks
43-
to [Corey Baker](https://github.com/cbaker6).
44-
4542
### 4.16.2
4643
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.16.1...4.16.2), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/4.16.2/documentation/parseswift)
4744

Diff for: ParseSwift.playground/Pages/1 - Your first Object.xcplaygroundpage/Contents.swift

+20-8
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
import PlaygroundSupport
88
import Foundation
99
import ParseSwift
10+
1011
PlaygroundPage.current.needsIndefiniteExecution = true
1112

12-
/*: start parse-server with
13-
npm start -- --appId applicationId --clientKey clientKey --masterKey masterKey --mountPath /1
13+
/*:
14+
Start your parse-server with:
15+
npm start -- --appId applicationId --clientKey clientKey --masterKey primaryKey --mountPath /1
1416
*/
1517

16-
//: In Xcode, make sure you are building the "ParseSwift (macOS)" framework.
17-
18-
initializeParse()
18+
do {
19+
try initializeParse()
20+
} catch {
21+
assertionFailure("Error initializing Parse-Swift: \(error)")
22+
}
1923

2024
//: Get current SDK version
2125
if let version = ParseVersion.current {
@@ -26,7 +30,7 @@ if let version = ParseVersion.current {
2630
do {
2731
print("Server health is: \(try ParseHealth.check())")
2832
} catch {
29-
print(error)
33+
assertionFailure("Error checking the server health: \(error)")
3034
}
3135

3236
//: Create your own value typed `ParseObject`.
@@ -79,7 +83,7 @@ struct GameData: ParseObject {
7983
//: Your own properties.
8084
var polygon: ParsePolygon?
8185
//: `ParseBytes` needs to be a part of the original schema
82-
//: or else you will need your masterKey to force an upgrade.
86+
//: or else you will need your primaryKey to force an upgrade.
8387
var bytes: ParseBytes?
8488

8589
/*:
@@ -125,6 +129,10 @@ score.save { result in
125129
assert(savedScore.createdAt != nil)
126130
assert(savedScore.updatedAt != nil)
127131
assert(savedScore.points == 10)
132+
print("""
133+
Saved \"\(savedScore.className)\" with the following info:
134+
\(savedScore)
135+
""")
128136

129137
/*:
130138
To modify, you need to make it a var as the value type
@@ -141,6 +149,10 @@ score.save { result in
141149
case .success(let savedChangedScore):
142150
assert(savedChangedScore.points == 200)
143151
assert(savedScore.objectId == savedChangedScore.objectId)
152+
print("""
153+
Updated \"\(savedScore.className)\" with the following info:
154+
\(savedChangedScore)
155+
""")
144156

145157
case .failure(let error):
146158
assertionFailure("Error saving: \(error)")
@@ -154,7 +166,7 @@ score.save { result in
154166
//: This will store the second batch score to be used later.
155167
var score2ForFetchedLater: GameScore?
156168

157-
//: Saving multiple GameScores at once.
169+
//: Saving multiple GameScores at once with batching.
158170
[score, score2].saveAll { results in
159171
switch results {
160172
case .success(let otherResults):

Diff for: ParseSwift.playground/Pages/10 - Cloud Code.xcplaygroundpage/Contents.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
//: Create your own value typed `ParseCloudable` type.
1722
struct Hello: ParseCloudable {

Diff for: ParseSwift.playground/Pages/11 - LiveQuery.xcplaygroundpage/Contents.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import SwiftUI
77

88
PlaygroundPage.current.needsIndefiniteExecution = true
99

10-
initializeParse()
10+
do {
11+
try initializeParse()
12+
} catch {
13+
assertionFailure("Error initializing Parse-Swift: \(error)")
14+
}
1115

1216
//: Create your own value typed ParseObject.
1317
struct GameScore: ParseObject {

Diff for: ParseSwift.playground/Pages/12 - Roles and Relations.xcplaygroundpage/Contents.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
struct User: ParseUser {
1722
//: These are required by `ParseObject`.

Diff for: ParseSwift.playground/Pages/13 - Operations.xcplaygroundpage/Contents.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
struct GameScore: ParseObject {
1722
//: These are required by ParseObject.

Diff for: ParseSwift.playground/Pages/14 - Config.xcplaygroundpage/Contents.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
//: Create a value typed `ParseConfig` that matches your server config.
1722
struct Config: ParseConfig {

Diff for: ParseSwift.playground/Pages/15 - Custom ObjectId.xcplaygroundpage/Contents.swift

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
import PlaygroundSupport
1010
import Foundation
1111
import ParseSwift
12+
1213
PlaygroundPage.current.needsIndefiniteExecution = true
1314

1415
/*:
15-
start parse-server with
16-
npm start -- --appId applicationId --clientKey clientKey --masterKey masterKey --mountPath /1
16+
Start parse-server with:
17+
npm start -- --appId applicationId --clientKey clientKey --masterKey primaryKey --mountPath /1
1718
*/
1819

19-
/*:
20-
In Xcode, make sure you are building the "ParseSwift (macOS)" framework.
21-
*/
22-
23-
initializeParse(customObjectId: true)
20+
do {
21+
try initializeParse(customObjectId: true)
22+
} catch {
23+
assertionFailure("Error initializing Parse-Swift: \(error)")
24+
}
2425

2526
//: Create your own value typed `ParseObject`.
2627
struct GameScore: ParseObject {

Diff for: ParseSwift.playground/Pages/16 - Analytics.xcplaygroundpage/Contents.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
//: To track when the app has been opened, do the following.
1722
ParseAnalytics.trackAppOpened { result in

Diff for: ParseSwift.playground/Pages/17 - SwiftUI - Finding Objects.xcplaygroundpage/Contents.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import SwiftUI
1515

1616
PlaygroundPage.current.needsIndefiniteExecution = true
1717

18-
initializeParse()
18+
do {
19+
try initializeParse()
20+
} catch {
21+
assertionFailure("Error initializing Parse-Swift: \(error)")
22+
}
1923

2024
//: Create your own value typed ParseObject.
2125
struct GameScore: ParseObject {

Diff for: ParseSwift.playground/Pages/18 - SwiftUI - Finding Objects With Custom ViewModel.xcplaygroundpage/Contents.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import Combine
1616

1717
PlaygroundPage.current.needsIndefiniteExecution = true
1818

19-
initializeParse()
19+
do {
20+
try initializeParse()
21+
} catch {
22+
assertionFailure("Error initializing Parse-Swift: \(error)")
23+
}
2024

2125
//: Create your own value typed ParseObject.
2226
struct GameScore: ParseObject {

Diff for: ParseSwift.playground/Pages/19 - SwiftUI - LiveQuery.xcplaygroundpage/Contents.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import SwiftUI
1515

1616
PlaygroundPage.current.needsIndefiniteExecution = true
1717

18-
initializeParse()
18+
do {
19+
try initializeParse()
20+
} catch {
21+
assertionFailure("Error initializing Parse-Swift: \(error)")
22+
}
1923

2024
//: Create your own value typed ParseObject.
2125
struct GameScore: ParseObject {

Diff for: ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
import PlaygroundSupport
1010
import Foundation
1111
import ParseSwift
12+
1213
PlaygroundPage.current.needsIndefiniteExecution = true
1314

14-
initializeParse()
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
struct GameScore: ParseObject {
1722
var objectId: String?

Diff for: ParseSwift.playground/Pages/20 - Cloud Schemas.xcplaygroundpage/Contents.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
/*:
44
The code in this Playground is intended to run at the
55
server level only. It is not intended to be run in client
6-
applications as it requires the use of the master key.
6+
applications as it requires the use of the primary key.
77
*/
88

99
import PlaygroundSupport
1010
import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
//: Youe specific _User value type.
1722
struct User: ParseUser {

Diff for: ParseSwift.playground/Pages/21 - Cloud Push Notifications.xcplaygroundpage/Contents.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
/*:
44
The code in this Playground is intended to run at the
55
server level only. It is not intended to be run in client
6-
applications as it requires the use of the master key.
6+
applications as it requires the use of the primary key.
77
*/
88

99
import PlaygroundSupport
1010
import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
struct Installation: ParseInstallation {
1722
//: These are required by `ParseObject`.

Diff for: ParseSwift.playground/Pages/22 - Cloud Hook Functions.xcplaygroundpage/Contents.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
/*:
44
The code in this Playground is intended to run at the
55
server level only. It is not intended to be run in client
6-
applications as it requires the use of the master key.
6+
applications as it requires the use of the primary key.
77
*/
88

99
import PlaygroundSupport
1010
import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
/*:
1722
Parse Hook Functions can be created by conforming to

Diff for: ParseSwift.playground/Pages/23 - Cloud Hook Triggers.xcplaygroundpage/Contents.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
/*:
44
The code in this Playground is intended to run at the
55
server level only. It is not intended to be run in client
6-
applications as it requires the use of the master key.
6+
applications as it requires the use of the primary key.
77
*/
88

99
import PlaygroundSupport
1010
import Foundation
1111
import ParseSwift
1212

1313
PlaygroundPage.current.needsIndefiniteExecution = true
14-
initializeParse()
14+
15+
do {
16+
try initializeParse()
17+
} catch {
18+
assertionFailure("Error initializing Parse-Swift: \(error)")
19+
}
1520

1621
//: Create your own value typed `ParseObject`.
1722
struct GameScore: ParseObject {

0 commit comments

Comments
 (0)