Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable async/await on older OS's #278

Merged
merged 37 commits into from Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1cc0440
fix: enable async/await on older OS's
cbaker6 Nov 9, 2021
6a2e76a
Remove Swift 5.5 restriction
cbaker6 Nov 9, 2021
8eac395
Add back Swift 5.5
cbaker6 Nov 9, 2021
21ddf8f
Merge branch 'main'
cbaker6 Nov 10, 2021
5af46ad
Merge branch 'main'
cbaker6 Nov 16, 2021
954d32c
merge with main
cbaker6 Nov 16, 2021
f08a2b4
Test build of @MainActor on extension
cbaker6 Nov 16, 2021
816fa63
make all extensions @MainActor
cbaker6 Nov 16, 2021
a62555d
Add more main actors
cbaker6 Nov 17, 2021
d320fb2
update changelog
cbaker6 Nov 17, 2021
2738fe4
user multiple cores when building
cbaker6 Nov 17, 2021
e470fa3
nit
cbaker6 Nov 17, 2021
3087d36
Merge branch 'main'
cbaker6 Nov 19, 2021
22b5b46
nit async docs
cbaker6 Nov 22, 2021
21735a9
more doc nits
cbaker6 Nov 22, 2021
df9c60f
clean tvOS test to prevent error
cbaker6 Nov 22, 2021
7ebfbbf
Merge branch 'main'
cbaker6 Nov 23, 2021
507f8b9
lint
cbaker6 Nov 24, 2021
f59c4d1
Don't use multiple cores
cbaker6 Nov 24, 2021
034b56a
nit
cbaker6 Nov 27, 2021
397e6c0
Merge remote-tracking branch 'refs/remotes/origin/concurrency'
cbaker6 Nov 27, 2021
6f6288d
Update ci.yml
cbaker6 Nov 29, 2021
67d627b
Merge branch 'main'
cbaker6 Nov 30, 2021
c976f65
Merge branch 'main'
cbaker6 Nov 30, 2021
dd25ebc
fix merge conflict
cbaker6 Nov 30, 2021
96fa606
Merge branch 'main'
cbaker6 Nov 30, 2021
66fd308
Merge branch 'main'
cbaker6 Dec 2, 2021
51e9b28
add more tests
cbaker6 Dec 2, 2021
cf0ddd8
add ParseRelation static methods & tests
cbaker6 Dec 2, 2021
50fa598
Retain original authData just incase an error occurs
cbaker6 Dec 3, 2021
db4d594
Merge branch 'main'
cbaker6 Dec 3, 2021
67ca9e4
don't force unwrap
cbaker6 Dec 7, 2021
d93a748
nit
cbaker6 Dec 7, 2021
eaabf98
Remove unnecessary dispatching
cbaker6 Dec 8, 2021
f01bead
Update .codecov.yml
cbaker6 Dec 8, 2021
2a97448
try multiple cores
cbaker6 Dec 8, 2021
26445a7
Prepare for release
cbaker6 Dec 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codecov.yml
Expand Up @@ -6,7 +6,7 @@ coverage:
status:
patch:
default:
target: auto
target: 71
changes: false
project:
default:
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Expand Up @@ -6,17 +6,15 @@ on:
branches: '*'
env:
CI_XCODE_VER: '/Applications/Xcode_11.7.app/Contents/Developer'
CI_XCODE_13: '/Applications/Xcode_13.1.app/Contents/Developer'
CI_XCODE_13: '/Applications/Xcode_13.2.app/Contents/Developer'

jobs:
xcode-test-ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Version
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -version
env:
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}
#- name: Use multiple cores
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
- name: Build-Test
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
env:
Expand Down Expand Up @@ -48,6 +46,8 @@ jobs:
security default-keychain -s temporary
security unlock-keychain -p "" temporary
security set-keychain-settings -lut 7200 temporary
#- name: Use multiple cores
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
- name: Build-Test
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
env:
Expand All @@ -73,6 +73,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
#- name: Use multiple cores
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
- name: Build
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
env:
Expand All @@ -98,6 +100,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
#- name: Use multiple cores
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
- name: Build
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -target ParseSwift\ \(watchOS\) | xcpretty
env:
Expand All @@ -119,6 +123,8 @@ jobs:
security default-keychain -s temporary
security unlock-keychain -p "" temporary
security set-keychain-settings -lut 7200 temporary
#- name: Use multiple cores
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
- name: Build and Test
run: swift test --enable-code-coverage -v
env:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -13,6 +13,8 @@ jobs:
- uses: actions/checkout@v2
- name: Get release version
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
# - name: Use multiple cores
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
- name: Update Framework Version
run: ./Scripts/update_build
env:
Expand Down Expand Up @@ -41,6 +43,8 @@ jobs:
bundle install
- name: Get release version
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
# - name: Use multiple cores
# run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
- name: Create Jazzy Docs
run: ./Scripts/jazzy.sh
env:
Expand Down
14 changes: 12 additions & 2 deletions CHANGELOG.md
Expand Up @@ -2,14 +2,24 @@

### main

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

### 2.4.0
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.3.1...2.4.0)

__Improvements__
- 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).
- 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).

__Fixes__
- 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).

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

__Fixes__
- 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).
- 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).

### 2.3.0
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.2.6...2.3.0)
Expand Down
Expand Up @@ -76,19 +76,19 @@ results.forEach { score in
//: Query highest score using async/await
#if swift(>=5.5) && canImport(_Concurrency)
import _Concurrency
if #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) {
let highestScoresQuery = GameScore.query("isHighest" == true)
Task {
do {
let highestScores = try await highestScoresQuery.find()
highestScores.forEach { score in
print("Found highest score: \(score)")
}
} catch {
print("Error: \(error)")

let highestScoresQuery = GameScore.query("isHighest" == true)
Task {
do {
let highestScores = try await highestScoresQuery.find()
highestScores.forEach { score in
print("Found highest score: \(score)")
}
} catch {
print("Error: \(error)")
}
}

#endif

//: Query first asynchronously (preferred way) - Performs work on background
Expand Down
8 changes: 4 additions & 4 deletions ParseSwift.xcodeproj/project.pbxproj
Expand Up @@ -1412,11 +1412,11 @@
706436A227341F36007C6461 /* Extensions */ = {
isa = PBXGroup;
children = (
F97B462C24D9C74400F4A88B /* URLSession.swift */,
9116F66E26A35D600082F6D6 /* URLCache.swift */,
706436A327341F6E007C6461 /* Encodable.swift */,
70386A0525D9718C0048EC1B /* Data.swift */,
706436A827341FD0007C6461 /* Date.swift */,
706436A327341F6E007C6461 /* Encodable.swift */,
9116F66E26A35D600082F6D6 /* URLCache.swift */,
F97B462C24D9C74400F4A88B /* URLSession.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -1464,8 +1464,8 @@
isa = PBXGroup;
children = (
707A3C1025B0A8E8000D215C /* ParseAnonymous.swift */,
703B092F26BF42C2005A112F /* ParseAnonymous+combine.swift */,
703B093426BF43D9005A112F /* ParseAnonymous+async.swift */,
703B092F26BF42C2005A112F /* ParseAnonymous+combine.swift */,
);
path = Internal;
sourceTree = "<group>";
Expand Down
Expand Up @@ -9,7 +9,7 @@
#if swift(>=5.5) && canImport(_Concurrency)
import Foundation

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@MainActor
public extension ParseApple {
// MARK: Async/Await

Expand All @@ -19,7 +19,7 @@ public extension ParseApple {
- parameter identityToken: The `identityToken` from `ASAuthorizationAppleIDCredential`.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(user: String,
identityToken: Data,
Expand All @@ -37,7 +37,7 @@ public extension ParseApple {
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
Expand All @@ -49,7 +49,7 @@ public extension ParseApple {
}
}

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@MainActor
public extension ParseApple {

/**
Expand All @@ -58,7 +58,7 @@ public extension ParseApple {
- parameter identityToken: The `identityToken` from `ASAuthorizationAppleIDCredential`.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(user: String,
identityToken: Data,
Expand All @@ -76,7 +76,7 @@ public extension ParseApple {
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
Expand Down
Expand Up @@ -9,7 +9,7 @@
#if swift(>=5.5) && canImport(_Concurrency)
import Foundation

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@MainActor
public extension ParseFacebook {
// MARK: Async/Await

Expand All @@ -20,7 +20,7 @@ public extension ParseFacebook {
- parameter expiresIn: Optional expiration in seconds for Facebook login.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(userId: String,
authenticationToken: String,
Expand All @@ -42,7 +42,7 @@ public extension ParseFacebook {
- parameter expiresIn: Optional expiration in seconds for Facebook login.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(userId: String,
accessToken: String,
Expand All @@ -61,7 +61,7 @@ public extension ParseFacebook {
Login a `ParseUser` *asynchronously* using Facebook authentication for graph API login.
- parameter authData: Dictionary containing key/values.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
Expand All @@ -73,7 +73,7 @@ public extension ParseFacebook {
}
}

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@MainActor
public extension ParseFacebook {
/**
Link the *current* `ParseUser` *asynchronously* using Facebook authentication for limited login.
Expand All @@ -82,7 +82,7 @@ public extension ParseFacebook {
- parameter expiresIn: Optional expiration in seconds for Facebook login.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(userId: String,
authenticationToken: String,
Expand All @@ -104,7 +104,7 @@ public extension ParseFacebook {
- parameter expiresIn: Optional expiration in seconds for Facebook login.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(userId: String,
accessToken: String,
Expand All @@ -124,7 +124,7 @@ public extension ParseFacebook {
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
Expand Down
Expand Up @@ -9,7 +9,7 @@
#if swift(>=5.5) && canImport(_Concurrency)
import Foundation

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@MainActor
public extension ParseLDAP {
// MARK: Async/Await
/**
Expand All @@ -18,7 +18,7 @@ public extension ParseLDAP {
- parameter password: The password of the user.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(id: String,
password: String,
Expand All @@ -36,7 +36,7 @@ public extension ParseLDAP {
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
Expand All @@ -48,15 +48,15 @@ public extension ParseLDAP {
}
}

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@MainActor
public extension ParseLDAP {
/**
Link the *current* `ParseUser` *asynchronously* using LDAP authentication.
- parameter id: The id of the `user`.
- parameter password: The password of the user.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(id: String,
password: String,
Expand All @@ -74,7 +74,7 @@ public extension ParseLDAP {
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
Expand Down
Expand Up @@ -9,7 +9,7 @@
#if swift(>=5.5) && canImport(_Concurrency)
import Foundation

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@MainActor
public extension ParseTwitter {
// MARK: Async/Await

Expand All @@ -23,7 +23,7 @@ public extension ParseTwitter {
- parameter authTokenSecret: The Twitter `authSecretToken` obtained from Twitter.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(userId: String,
screenName: String? = nil,
Expand All @@ -49,7 +49,7 @@ public extension ParseTwitter {
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func login(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
Expand All @@ -61,7 +61,7 @@ public extension ParseTwitter {
}
}

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
@MainActor
public extension ParseTwitter {

/**
Expand All @@ -74,7 +74,7 @@ public extension ParseTwitter {
- parameter authTokenSecret: The Twitter `authSecretToken` obtained from Twitter.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(userId: String,
screenName: String? = nil,
Expand All @@ -100,7 +100,7 @@ public extension ParseTwitter {
- parameter authData: Dictionary containing key/values.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: An instance of the logged in `ParseUser`.
- throws: `ParseError`.
- throws: An error of type `ParseError`..
*/
func link(authData: [String: String],
options: API.Options = []) async throws -> AuthenticatedUser {
Expand Down