Skip to content

Commit ccbbb33

Browse files
authored
feat: enable async/await on older OS's (#278)
* fix: enable async/await on older OS's * Remove Swift 5.5 restriction * Add back Swift 5.5 * merge with main * Test build of @mainactor on extension * make all extensions @mainactor * Add more main actors * update changelog * user multiple cores when building * nit * nit async docs * more doc nits * clean tvOS test to prevent error * lint * Don't use multiple cores * nit * Update ci.yml * fix merge conflict * add more tests * add ParseRelation static methods & tests * Retain original authData just incase an error occurs * don't force unwrap * nit * Remove unnecessary dispatching * Update .codecov.yml * try multiple cores * Prepare for release
1 parent ae6de04 commit ccbbb33

File tree

66 files changed

+611
-398
lines changed

Some content is hidden

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

66 files changed

+611
-398
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ coverage:
66
status:
77
patch:
88
default:
9-
target: auto
9+
target: 71
1010
changes: false
1111
project:
1212
default:

.github/workflows/ci.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ on:
66
branches: '*'
77
env:
88
CI_XCODE_VER: '/Applications/Xcode_11.7.app/Contents/Developer'
9-
CI_XCODE_13: '/Applications/Xcode_13.1.app/Contents/Developer'
9+
CI_XCODE_13: '/Applications/Xcode_13.2.app/Contents/Developer'
1010

1111
jobs:
1212
xcode-test-ios:
1313
runs-on: macos-latest
1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Version
17-
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -version
18-
env:
19-
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}
16+
#- name: Use multiple cores
17+
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
2018
- name: Build-Test
2119
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace Parse.xcworkspace -scheme ParseSwift\ \(iOS\) -destination platform\=iOS\ Simulator,name\=iPhone\ 12\ Pro\ Max -derivedDataPath DerivedData -test-iterations 10 -retry-tests-on-failure clean test | xcpretty
2220
env:
@@ -48,6 +46,8 @@ jobs:
4846
security default-keychain -s temporary
4947
security unlock-keychain -p "" temporary
5048
security set-keychain-settings -lut 7200 temporary
49+
#- name: Use multiple cores
50+
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
5151
- name: Build-Test
5252
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace Parse.xcworkspace -scheme ParseSwift\ \(macOS\) -destination platform\=macOS -derivedDataPath DerivedData -test-iterations 10 -retry-tests-on-failure clean test | xcpretty
5353
env:
@@ -73,6 +73,8 @@ jobs:
7373
runs-on: macos-latest
7474
steps:
7575
- uses: actions/checkout@v2
76+
#- name: Use multiple cores
77+
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
7678
- name: Build
7779
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace Parse.xcworkspace -scheme ParseSwift\ \(tvOS\) -destination platform\=tvOS\ Simulator,name\=Apple\ TV -derivedDataPath DerivedData -test-iterations 10 -retry-tests-on-failure clean test | xcpretty
7880
env:
@@ -98,6 +100,8 @@ jobs:
98100
runs-on: macos-latest
99101
steps:
100102
- uses: actions/checkout@v2
103+
#- name: Use multiple cores
104+
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
101105
- name: Build
102106
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -target ParseSwift\ \(watchOS\) | xcpretty
103107
env:
@@ -119,6 +123,8 @@ jobs:
119123
security default-keychain -s temporary
120124
security unlock-keychain -p "" temporary
121125
security set-keychain-settings -lut 7200 temporary
126+
#- name: Use multiple cores
127+
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
122128
- name: Build and Test
123129
run: swift test --enable-code-coverage -v
124130
env:

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
- uses: actions/checkout@v2
1414
- name: Get release version
1515
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
16+
# - name: Use multiple cores
17+
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
1618
- name: Update Framework Version
1719
run: ./Scripts/update_build
1820
env:
@@ -41,6 +43,8 @@ jobs:
4143
bundle install
4244
- name: Get release version
4345
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
46+
# - name: Use multiple cores
47+
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
4448
- name: Create Jazzy Docs
4549
run: ./Scripts/jazzy.sh
4650
env:

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@
22

33
### main
44

5-
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.3.1...main)
5+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.4.0...main)
66
* _Contributing to this repo? Add info about your change here to be included in the next release_
77

8+
### 2.4.0
9+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.3.1...2.4.0)
10+
11+
__Improvements__
12+
- Added additional methods to ParseRelation to make it easier to create and query relations ([#294](https://github.com/parse-community/Parse-Swift/pull/294)), thanks to [Corey Baker](https://github.com/cbaker6).
13+
- Enable async/await for iOS13, tvOS13, watchOS6, and macOS10_15. All async/await methods are @MainActor's. Requires Xcode 13.2 or above to use async/await. Not compatible with Xcode 13.0/1, will need to upgrade to 13.2+. Still works with Xcode 11/12 ([#278](https://github.com/parse-community/Parse-Swift/pull/278)), thanks to [Corey Baker](https://github.com/cbaker6).
14+
15+
__Fixes__
16+
- When transactions are enabled errors are now thrown from the client if the amount of objects in a transaction exceeds the batch size. An error will also be thrown if a developer attempts to save objects in a transation that has unsaved children ([#295](https://github.com/parse-community/Parse-Swift/pull/294)), thanks to [Corey Baker](https://github.com/cbaker6).
17+
818
### 2.3.1
919
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.3.0...2.3.1)
1020

1121
__Fixes__
12-
- Fixed an issue querying an object didn't dispatch to the proper queue which can cause app crashes ([#293](https://github.com/parse-community/Parse-Swift/pull/293)), thanks to [Corey Baker](https://github.com/cbaker6).
22+
- Fixed an issue where querying an object didn't dispatch to the proper queue which can cause app crashes ([#293](https://github.com/parse-community/Parse-Swift/pull/293)), thanks to [Corey Baker](https://github.com/cbaker6).
1323

1424
### 2.3.0
1525
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.2.6...2.3.0)

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@ results.forEach { score in
7676
//: Query highest score using async/await
7777
#if swift(>=5.5) && canImport(_Concurrency)
7878
import _Concurrency
79-
if #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) {
80-
let highestScoresQuery = GameScore.query("isHighest" == true)
81-
Task {
82-
do {
83-
let highestScores = try await highestScoresQuery.find()
84-
highestScores.forEach { score in
85-
print("Found highest score: \(score)")
86-
}
87-
} catch {
88-
print("Error: \(error)")
79+
80+
let highestScoresQuery = GameScore.query("isHighest" == true)
81+
Task {
82+
do {
83+
let highestScores = try await highestScoresQuery.find()
84+
highestScores.forEach { score in
85+
print("Found highest score: \(score)")
8986
}
87+
} catch {
88+
print("Error: \(error)")
9089
}
9190
}
91+
9292
#endif
9393

9494
//: Query first asynchronously (preferred way) - Performs work on background

ParseSwift.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,11 +1412,11 @@
14121412
706436A227341F36007C6461 /* Extensions */ = {
14131413
isa = PBXGroup;
14141414
children = (
1415-
F97B462C24D9C74400F4A88B /* URLSession.swift */,
1416-
9116F66E26A35D600082F6D6 /* URLCache.swift */,
1417-
706436A327341F6E007C6461 /* Encodable.swift */,
14181415
70386A0525D9718C0048EC1B /* Data.swift */,
14191416
706436A827341FD0007C6461 /* Date.swift */,
1417+
706436A327341F6E007C6461 /* Encodable.swift */,
1418+
9116F66E26A35D600082F6D6 /* URLCache.swift */,
1419+
F97B462C24D9C74400F4A88B /* URLSession.swift */,
14201420
);
14211421
path = Extensions;
14221422
sourceTree = "<group>";
@@ -1464,8 +1464,8 @@
14641464
isa = PBXGroup;
14651465
children = (
14661466
707A3C1025B0A8E8000D215C /* ParseAnonymous.swift */,
1467-
703B092F26BF42C2005A112F /* ParseAnonymous+combine.swift */,
14681467
703B093426BF43D9005A112F /* ParseAnonymous+async.swift */,
1468+
703B092F26BF42C2005A112F /* ParseAnonymous+combine.swift */,
14691469
);
14701470
path = Internal;
14711471
sourceTree = "<group>";

Sources/ParseSwift/Authentication/3rd Party/ParseApple/ParseApple+async.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#if swift(>=5.5) && canImport(_Concurrency)
1010
import Foundation
1111

12-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
12+
@MainActor
1313
public extension ParseApple {
1414
// MARK: Async/Await
1515

@@ -19,7 +19,7 @@ public extension ParseApple {
1919
- parameter identityToken: The `identityToken` from `ASAuthorizationAppleIDCredential`.
2020
- parameter options: A set of header options sent to the server. Defaults to an empty set.
2121
- returns: An instance of the logged in `ParseUser`.
22-
- throws: `ParseError`.
22+
- throws: An error of type `ParseError`..
2323
*/
2424
func login(user: String,
2525
identityToken: Data,
@@ -37,7 +37,7 @@ public extension ParseApple {
3737
- parameter authData: Dictionary containing key/values.
3838
- parameter options: A set of header options sent to the server. Defaults to an empty set.
3939
- returns: An instance of the logged in `ParseUser`.
40-
- throws: `ParseError`.
40+
- throws: An error of type `ParseError`..
4141
*/
4242
func login(authData: [String: String],
4343
options: API.Options = []) async throws -> AuthenticatedUser {
@@ -49,7 +49,7 @@ public extension ParseApple {
4949
}
5050
}
5151

52-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
52+
@MainActor
5353
public extension ParseApple {
5454

5555
/**
@@ -58,7 +58,7 @@ public extension ParseApple {
5858
- parameter identityToken: The `identityToken` from `ASAuthorizationAppleIDCredential`.
5959
- parameter options: A set of header options sent to the server. Defaults to an empty set.
6060
- returns: An instance of the logged in `ParseUser`.
61-
- throws: `ParseError`.
61+
- throws: An error of type `ParseError`..
6262
*/
6363
func link(user: String,
6464
identityToken: Data,
@@ -76,7 +76,7 @@ public extension ParseApple {
7676
- parameter authData: Dictionary containing key/values.
7777
- parameter options: A set of header options sent to the server. Defaults to an empty set.
7878
- returns: An instance of the logged in `ParseUser`.
79-
- throws: `ParseError`.
79+
- throws: An error of type `ParseError`..
8080
*/
8181
func link(authData: [String: String],
8282
options: API.Options = []) async throws -> AuthenticatedUser {

Sources/ParseSwift/Authentication/3rd Party/ParseFacebook/ParseFacebook+async.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#if swift(>=5.5) && canImport(_Concurrency)
1010
import Foundation
1111

12-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
12+
@MainActor
1313
public extension ParseFacebook {
1414
// MARK: Async/Await
1515

@@ -20,7 +20,7 @@ public extension ParseFacebook {
2020
- parameter expiresIn: Optional expiration in seconds for Facebook login.
2121
- parameter options: A set of header options sent to the server. Defaults to an empty set.
2222
- returns: An instance of the logged in `ParseUser`.
23-
- throws: `ParseError`.
23+
- throws: An error of type `ParseError`..
2424
*/
2525
func login(userId: String,
2626
authenticationToken: String,
@@ -42,7 +42,7 @@ public extension ParseFacebook {
4242
- parameter expiresIn: Optional expiration in seconds for Facebook login.
4343
- parameter options: A set of header options sent to the server. Defaults to an empty set.
4444
- returns: An instance of the logged in `ParseUser`.
45-
- throws: `ParseError`.
45+
- throws: An error of type `ParseError`..
4646
*/
4747
func login(userId: String,
4848
accessToken: String,
@@ -61,7 +61,7 @@ public extension ParseFacebook {
6161
Login a `ParseUser` *asynchronously* using Facebook authentication for graph API login.
6262
- parameter authData: Dictionary containing key/values.
6363
- returns: An instance of the logged in `ParseUser`.
64-
- throws: `ParseError`.
64+
- throws: An error of type `ParseError`..
6565
*/
6666
func login(authData: [String: String],
6767
options: API.Options = []) async throws -> AuthenticatedUser {
@@ -73,7 +73,7 @@ public extension ParseFacebook {
7373
}
7474
}
7575

76-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
76+
@MainActor
7777
public extension ParseFacebook {
7878
/**
7979
Link the *current* `ParseUser` *asynchronously* using Facebook authentication for limited login.
@@ -82,7 +82,7 @@ public extension ParseFacebook {
8282
- parameter expiresIn: Optional expiration in seconds for Facebook login.
8383
- parameter options: A set of header options sent to the server. Defaults to an empty set.
8484
- returns: An instance of the logged in `ParseUser`.
85-
- throws: `ParseError`.
85+
- throws: An error of type `ParseError`..
8686
*/
8787
func link(userId: String,
8888
authenticationToken: String,
@@ -104,7 +104,7 @@ public extension ParseFacebook {
104104
- parameter expiresIn: Optional expiration in seconds for Facebook login.
105105
- parameter options: A set of header options sent to the server. Defaults to an empty set.
106106
- returns: An instance of the logged in `ParseUser`.
107-
- throws: `ParseError`.
107+
- throws: An error of type `ParseError`..
108108
*/
109109
func link(userId: String,
110110
accessToken: String,
@@ -124,7 +124,7 @@ public extension ParseFacebook {
124124
- parameter authData: Dictionary containing key/values.
125125
- parameter options: A set of header options sent to the server. Defaults to an empty set.
126126
- returns: An instance of the logged in `ParseUser`.
127-
- throws: `ParseError`.
127+
- throws: An error of type `ParseError`..
128128
*/
129129
func link(authData: [String: String],
130130
options: API.Options = []) async throws -> AuthenticatedUser {

Sources/ParseSwift/Authentication/3rd Party/ParseLDAP/ParseLDAP+async.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#if swift(>=5.5) && canImport(_Concurrency)
1010
import Foundation
1111

12-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
12+
@MainActor
1313
public extension ParseLDAP {
1414
// MARK: Async/Await
1515
/**
@@ -18,7 +18,7 @@ public extension ParseLDAP {
1818
- parameter password: The password of the user.
1919
- parameter options: A set of header options sent to the server. Defaults to an empty set.
2020
- returns: An instance of the logged in `ParseUser`.
21-
- throws: `ParseError`.
21+
- throws: An error of type `ParseError`..
2222
*/
2323
func login(id: String,
2424
password: String,
@@ -36,7 +36,7 @@ public extension ParseLDAP {
3636
- parameter authData: Dictionary containing key/values.
3737
- parameter options: A set of header options sent to the server. Defaults to an empty set.
3838
- returns: An instance of the logged in `ParseUser`.
39-
- throws: `ParseError`.
39+
- throws: An error of type `ParseError`..
4040
*/
4141
func login(authData: [String: String],
4242
options: API.Options = []) async throws -> AuthenticatedUser {
@@ -48,15 +48,15 @@ public extension ParseLDAP {
4848
}
4949
}
5050

51-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
51+
@MainActor
5252
public extension ParseLDAP {
5353
/**
5454
Link the *current* `ParseUser` *asynchronously* using LDAP authentication.
5555
- parameter id: The id of the `user`.
5656
- parameter password: The password of the user.
5757
- parameter options: A set of header options sent to the server. Defaults to an empty set.
5858
- returns: An instance of the logged in `ParseUser`.
59-
- throws: `ParseError`.
59+
- throws: An error of type `ParseError`..
6060
*/
6161
func link(id: String,
6262
password: String,
@@ -74,7 +74,7 @@ public extension ParseLDAP {
7474
- parameter authData: Dictionary containing key/values.
7575
- parameter options: A set of header options sent to the server. Defaults to an empty set.
7676
- returns: An instance of the logged in `ParseUser`.
77-
- throws: `ParseError`.
77+
- throws: An error of type `ParseError`..
7878
*/
7979
func link(authData: [String: String],
8080
options: API.Options = []) async throws -> AuthenticatedUser {

Sources/ParseSwift/Authentication/3rd Party/ParseTwitter/ParseTwitter+async.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#if swift(>=5.5) && canImport(_Concurrency)
1010
import Foundation
1111

12-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
12+
@MainActor
1313
public extension ParseTwitter {
1414
// MARK: Async/Await
1515

@@ -23,7 +23,7 @@ public extension ParseTwitter {
2323
- parameter authTokenSecret: The Twitter `authSecretToken` obtained from Twitter.
2424
- parameter options: A set of header options sent to the server. Defaults to an empty set.
2525
- returns: An instance of the logged in `ParseUser`.
26-
- throws: `ParseError`.
26+
- throws: An error of type `ParseError`..
2727
*/
2828
func login(userId: String,
2929
screenName: String? = nil,
@@ -49,7 +49,7 @@ public extension ParseTwitter {
4949
- parameter authData: Dictionary containing key/values.
5050
- parameter options: A set of header options sent to the server. Defaults to an empty set.
5151
- returns: An instance of the logged in `ParseUser`.
52-
- throws: `ParseError`.
52+
- throws: An error of type `ParseError`..
5353
*/
5454
func login(authData: [String: String],
5555
options: API.Options = []) async throws -> AuthenticatedUser {
@@ -61,7 +61,7 @@ public extension ParseTwitter {
6161
}
6262
}
6363

64-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
64+
@MainActor
6565
public extension ParseTwitter {
6666

6767
/**
@@ -74,7 +74,7 @@ public extension ParseTwitter {
7474
- parameter authTokenSecret: The Twitter `authSecretToken` obtained from Twitter.
7575
- parameter options: A set of header options sent to the server. Defaults to an empty set.
7676
- returns: An instance of the logged in `ParseUser`.
77-
- throws: `ParseError`.
77+
- throws: An error of type `ParseError`..
7878
*/
7979
func link(userId: String,
8080
screenName: String? = nil,
@@ -100,7 +100,7 @@ public extension ParseTwitter {
100100
- parameter authData: Dictionary containing key/values.
101101
- parameter options: A set of header options sent to the server. Defaults to an empty set.
102102
- returns: An instance of the logged in `ParseUser`.
103-
- throws: `ParseError`.
103+
- throws: An error of type `ParseError`..
104104
*/
105105
func link(authData: [String: String],
106106
options: API.Options = []) async throws -> AuthenticatedUser {

0 commit comments

Comments
 (0)