Skip to content

Commit

Permalink
feat: add migration from Obj-C SDK to Swift SDK (#391)
Browse files Browse the repository at this point in the history
* fix changelog

* feat: add migration from Obj-C SDK to Swift SDK

* don't build new methods on linux, windows, android

* nits

* consolidate objc keychain calls

* add migrate and delete methods for ParseInstallation

* don't build async for linux

* change default installation behavior

* add loginUsingObjCKeychain tests

* lint

* add combine tests

* make installation methods static

* add tests

* nits
  • Loading branch information
cbaker6 committed Aug 22, 2022
1 parent 675168e commit 89e5e69
Show file tree
Hide file tree
Showing 89 changed files with 2,695 additions and 380 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Expand Up @@ -6,7 +6,7 @@ coverage:
status:
patch:
default:
target: 33
target: 75
changes: false
project:
default:
Expand Down
40 changes: 25 additions & 15 deletions CHANGELOG.md
@@ -1,15 +1,25 @@
# Parse-Swift Changelog

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

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

__New features__
- Add methods for migrating users and installations from the Parse Objective-C SDK to the Swift SDK ([#391](https://github.com/parse-community/Parse-Swift/pull/391)), thanks to [Corey Baker](https://github.com/cbaker6).
- Enable query caching by using GET instead of POST. GET is now used by default. To switch back to POST, set usingPostForQuery = true when initializing the SDK which will automatically disable all query caching ([#386](https://github.com/parse-community/Parse-Swift/pull/386)), thanks to [Corey Baker](https://github.com/cbaker6).

__Improvements__
- Add more details to error messages related when decoding errors occur ([#388](https://github.com/parse-community/Parse-Swift/pull/388)), thanks to [Daniel Blyth](https://github.com/dblythy).
- Added discardableResult to allow developers to choose whether or not certain functions should return a result ([#385](https://github.com/parse-community/Parse-Swift/pull/385)), thanks to [Damian Van de Kauter](https://github.com/vdkdamian).

[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.8.0...main)
* _Contributing to this repo? Add info about your change here to be included in the next release_
__Fixes__
- Ensure properties that are already saved ParseObject's are converted to Parse pointers when using saveAll ([#390](https://github.com/parse-community/Parse-Swift/pull/390)), thanks to [Corey Baker](https://github.com/cbaker6).

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

__New features__
- Add ParseSpotify authentication ([#375](https://github.com/parse-community/Parse-Swift/pull/375)), thanks to [Ulaş Sancak](https://github.com/rocxteady).
Expand Down Expand Up @@ -168,7 +178,7 @@ __Fixes__
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.3.0...2.3.1)

__Fixes__
- 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).
- Fixed an issue where querying an object did not 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 All @@ -178,7 +188,7 @@ __New features__
- Add toCLLocation and toCLLocationCoordinate2D methods for easy conversion from a ParseGeoPoint object ([#287](https://github.com/parse-community/Parse-Swift/pull/287)), thanks to [Jayson Ng](https://github.com/jaysonng).

__Fixes__
- Fixed an issue where an annonymous couldn't be turned into a regular user using signup ([#291](https://github.com/parse-community/Parse-Swift/pull/291)), thanks to [Corey Baker](https://github.com/cbaker6).
- Fixed an issue where an annonymous could not be turned into a regular user using signup ([#291](https://github.com/parse-community/Parse-Swift/pull/291)), thanks to [Corey Baker](https://github.com/cbaker6).
- The default ACL is now deleted from the keychain when a user is logged out. This previously caused an issue when logging out a user and logging in as a different user caused all objects to only have ACL permisions for the logged in user ([#291](https://github.com/parse-community/Parse-Swift/pull/291)), thanks to [Corey Baker](https://github.com/cbaker6).

### 2.2.6
Expand Down Expand Up @@ -225,7 +235,7 @@ __Improvements__
- Added ability to fetch ParsePointer using async/await ([#271](https://github.com/parse-community/Parse-Swift/pull/271)), thanks to [Corey Baker](https://github.com/cbaker6).

__Fixes__
- By default, don't use cache when fetching ParseObject's and ParseFile's. Developers can choose to fetch from cache if desired by passing the necessary option while fetching. Fixed a bug when the incorrect file location for a dowloaded ParseFile was being cached ([#272](https://github.com/parse-community/Parse-Swift/pull/272)), thanks to [Corey Baker](https://github.com/cbaker6).
- By default, do not use cache when fetching ParseObject's and ParseFile's. Developers can choose to fetch from cache if desired by passing the necessary option while fetching. Fixed a bug when the incorrect file location for a dowloaded ParseFile was being cached ([#272](https://github.com/parse-community/Parse-Swift/pull/272)), thanks to [Corey Baker](https://github.com/cbaker6).

### 2.1.0
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.0.3...2.1.0)
Expand Down Expand Up @@ -306,13 +316,13 @@ __Improvements__
- (Breaking Change) Provide ParseObject property, emptyObject, that makes it easy to send only modified keys to the server. This change "might" be breaking depending on your implementation as it requires ParseObjects to now have an empty initializer, init() ([#243](https://github.com/parse-community/Parse-Swift/pull/243)), thanks to [Corey Baker](https://github.com/cbaker6).

__Fixes__
- ParseUser shouldn't send email if it hasn't been modified or else email verification is resent ([#241](https://github.com/parse-community/Parse-Swift/pull/241)), thanks to [Corey Baker](https://github.com/cbaker6).
- ParseUser should not send email if it has not been modified or else email verification is resent ([#241](https://github.com/parse-community/Parse-Swift/pull/241)), thanks to [Corey Baker](https://github.com/cbaker6).

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

__Fixes__
- ParseInstallation can't be retreived from Keychain after the first fun ([#236](https://github.com/parse-community/Parse-Swift/pull/236)), thanks to [Corey Baker](https://github.com/cbaker6).
- ParseInstallation cannot be retreived from Keychain after the first fun ([#236](https://github.com/parse-community/Parse-Swift/pull/236)), thanks to [Corey Baker](https://github.com/cbaker6).

### 1.9.9
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.9.8...1.9.9)
Expand Down Expand Up @@ -386,13 +396,13 @@ __New features__
__Improvements__
- Removed CommonCrypto and now uses encoded string as a hash for child ParseObjects across all OS's ([#184](https://github.com/parse-community/Parse-Swift/pull/184)), thanks to [Corey Baker](https://github.com/cbaker6).
- All types now conform to CustomStringConvertible ([#185](https://github.com/parse-community/Parse-Swift/pull/185)), thanks to [Corey Baker](https://github.com/cbaker6).
- Setting limit = 0 of a query doesn't query the server and instead just returns empty or no results depending on the query ([#189](https://github.com/parse-community/Parse-Swift/pull/189)), thanks to [Corey Baker](https://github.com/cbaker6).
- Setting limit = 0 of a query does not query the server and instead just returns empty or no results depending on the query ([#189](https://github.com/parse-community/Parse-Swift/pull/189)), thanks to [Corey Baker](https://github.com/cbaker6).
- ParseGeoPoint initializer now throws if geopoints are out-of-bounds instead of asserting ([#190](https://github.com/parse-community/Parse-Swift/pull/190)), thanks to [Corey Baker](https://github.com/cbaker6).
- Persist all properties of ParseUser and ParseInstallation to keychain so they can be accessed via current. Developers don't have to fetch the ParseUser or ParseInstlation after app restart anymore ([#191](https://github.com/parse-community/Parse-Swift/pull/191)), thanks to [Corey Baker](https://github.com/cbaker6).
- Persist all properties of ParseUser and ParseInstallation to keychain so they can be accessed via current. Developers do not have to fetch the ParseUser or ParseInstlation after app restart anymore ([#191](https://github.com/parse-community/Parse-Swift/pull/191)), thanks to [Corey Baker](https://github.com/cbaker6).

__Fixes__
- Fixed a bug when signing up from a ParseUser instance resulted in custom keys not being persisted to the keychain ([#187](https://github.com/parse-community/Parse-Swift/pull/187)), thanks to [Corey Baker](https://github.com/cbaker6).
- Fixed a bug where countExplain query result wasn't returned as an array ([#189](https://github.com/parse-community/Parse-Swift/pull/189)), thanks to [Corey Baker](https://github.com/cbaker6).
- Fixed a bug where countExplain query result was not returned as an array ([#189](https://github.com/parse-community/Parse-Swift/pull/189)), thanks to [Corey Baker](https://github.com/cbaker6).
- The query withinPolygon(key: String, points: [ParseGeoPoint]) now works correctly and sends an array of doubles instead of an array of GeoPoint's ([#190](https://github.com/parse-community/Parse-Swift/pull/190)), thanks to [Corey Baker](https://github.com/cbaker6).
- Fixed a bug where the ParseEncoder incorrectly detects a circular dependency when two child objects are the same ([#194](https://github.com/parse-community/Parse-Swift/pull/194)), thanks to [Corey Baker](https://github.com/cbaker6).
- Make sure all LiveQuery socket changes are received on the correct queue to prevent threading issues ([#195](https://github.com/parse-community/Parse-Swift/pull/195)), thanks to [Corey Baker](https://github.com/cbaker6).
Expand Down Expand Up @@ -440,7 +450,7 @@ __Improvements__
- Append instead of replace when using query select, exclude, include, and fields ([#155](https://github.com/parse-community/Parse-Swift/pull/155)), thanks to [Corey Baker](https://github.com/cbaker6).

__Fixes__
- Transactions currently don't work when using MongoDB(postgres does work) on the parse-server. Internal use of transactions are disabled by default. If you want the Swift SDK to use transactions internally, you need to set isUsingTransactionsInternally=true when configuring the client. It is recommended not to use transactions if you are using MongoDB until it's fixed on the server ([#158](https://github.com/parse-community/Parse-Swift/pull/158)), thanks to [Corey Baker](https://github.com/cbaker6).
- Transactions currently do not work when using MongoDB(postgres does work) on the parse-server. Internal use of transactions are disabled by default. If you want the Swift SDK to use transactions internally, you need to set isUsingTransactionsInternally=true when configuring the client. It is recommended not to use transactions if you are using MongoDB until it is fixed on the server ([#158](https://github.com/parse-community/Parse-Swift/pull/158)), thanks to [Corey Baker](https://github.com/cbaker6).

### 1.8.0
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.7.2...1.8.0)
Expand All @@ -462,7 +472,7 @@ __New features__
- Added ability to send context with object by specifying it within options ([#140](https://github.com/parse-community/Parse-Swift/pull/140)), thanks to [Corey Baker](https://github.com/cbaker6).

__Fixes__
- ParseFiles can't be updated from the client and will now throw an error if attempted. Instead another file should be created and the older file should be deleted by the developer. ([#144](https://github.com/parse-community/Parse-Swift/pull/144)), thanks to [Corey Baker](https://github.com/cbaker6).
- ParseFiles cannot be updated from the client and will now throw an error if attempted. Instead another file should be created and the older file should be deleted by the developer. ([#144](https://github.com/parse-community/Parse-Swift/pull/144)), thanks to [Corey Baker](https://github.com/cbaker6).
- Fixed issue where Swift SDK prevented fetching of Parse objects when custom objectId was enabled ([#139](https://github.com/parse-community/Parse-Swift/pull/139)), thanks to [Corey Baker](https://github.com/cbaker6).

__Improvements__
Expand Down Expand Up @@ -497,7 +507,7 @@ __Improvements__
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.4.0...1.5.0)

__Improvements__
- (Breaking Change) Aggregrate takes any Encodable type. Query planning methods are now: findExlpain, firstEplain, countExplain, etc. The distinct query now works. The client will also not throw an error anymore when attempting to delete a File and the masterKey isn't available. The developer will still need to configure the server to delete the file properly ([#122](https://github.com/parse-community/Parse-Swift/pull/122)), thanks to [Corey Baker](https://github.com/cbaker6).
- (Breaking Change) Aggregrate takes any Encodable type. Query planning methods are now: findExlpain, firstEplain, countExplain, etc. The distinct query now works. The client will also not throw an error anymore when attempting to delete a File and the masterKey is not available. The developer will still need to configure the server to delete the file properly ([#122](https://github.com/parse-community/Parse-Swift/pull/122)), thanks to [Corey Baker](https://github.com/cbaker6).

### 1.4.0
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.3.1...1.4.0)
Expand Down Expand Up @@ -559,7 +569,7 @@ __New features__
- Add build support for Android ([#90](https://github.com/parse-community/Parse-Swift/pull/90)), thanks to [jt9897253](https://github.com/jt9897253).

__Fixes__
- There was another bug after a user first logs in anonymously and then becomes a real user. The authData sent to the server wasn't stripped, keep the user anonymous instead of making them a real user ([#100](https://github.com/parse-community/Parse-Swift/pull/100)), thanks to [Corey Baker](https://github.com/cbaker6).
- There was another bug after a user first logs in anonymously and then becomes a real user. The authData sent to the server was not stripped, keep the user anonymous instead of making them a real user ([#100](https://github.com/parse-community/Parse-Swift/pull/100)), thanks to [Corey Baker](https://github.com/cbaker6).

### 1.2.1
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.0...1.2.1)
Expand Down Expand Up @@ -679,7 +689,7 @@ __Improvements__

__Fixes__
- Delete current installation during logout ([#52](https://github.com/parse-community/Parse-Swift/pull/52)), thanks to [Corey Baker](https://github.com/cbaker6).
- Parse server supports `$eq`, but this isn't supported by LiveQueryServer, switched to supported ([#49](https://github.com/parse-community/Parse-Swift/pull/49)), thanks to [Corey Baker](https://github.com/cbaker6).
- Parse server supports `$eq`, but this is not supported by LiveQueryServer, switched to supported ([#49](https://github.com/parse-community/Parse-Swift/pull/49)), thanks to [Corey Baker](https://github.com/cbaker6).
- Bug when updating a ParseObject bug where objects was accidently converted to pointers ([#48](https://github.com/parse-community/Parse-Swift/pull/48)), thanks to [Corey Baker](https://github.com/cbaker6).
- User logout was calling the wrong endpoint ([#43](https://github.com/parse-community/Parse-Swift/pull/43)), thanks to [Corey Baker](https://github.com/cbaker6) and [Tom Fox](https://github.com/TomWFox).
- Fix an issue where ACL was overwritten with nil ([#40](https://github.com/parse-community/Parse-Swift/pull/40)), thanks to [Corey Baker](https://github.com/cbaker6).
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -27,7 +27,7 @@ Together we will plan out the best conceptual approach for your contribution, so

When you are ready to code, you can find more information about opening a pull request in the [GitHub docs](https://help.github.com/articles/creating-a-pull-request/).

Whether this is your first contribution or you are already an experienced contributor, the Parse Community has your back – don't hesitate to ask for help!
Whether this is your first contribution or you are already an experienced contributor, the Parse Community has your back – do not hesitate to ask for help!

## Why Contributing?

Expand Down
Expand Up @@ -121,7 +121,7 @@ score.save { result in
assert(savedScore.points == 10)

/*: To modify, need to make it a var as the value type
was initialized as immutable. Using `mutable`
was initialized as immutable. Using `mergeable`
allows you to only send the updated keys to the
parse server as opposed to the whole object.
*/
Expand Down Expand Up @@ -195,7 +195,7 @@ var score2ForFetchedLater: GameScore?
}
}*/

//: Save synchronously (not preferred - all operations on main queue).
//: Save synchronously (not preferred - all operations on current queue).
let savedScore: GameScore?
do {
savedScore = try score.save()
Expand All @@ -211,7 +211,7 @@ assert(savedScore?.updatedAt != nil)
assert(savedScore?.points == 10)

/*: To modify, need to make it a var as the value type
was initialized as immutable. Using `mutable`
was initialized as immutable. Using `mergeable`
allows you to only send the updated keys to the
parse server as opposed to the whole object.
*/
Expand Down Expand Up @@ -274,7 +274,7 @@ do {
//: Now we will fetch a ParseObject that has already been saved based on its' objectId.
let scoreToFetch = GameScore(objectId: savedScore?.objectId)

//: Asynchronously (preferred way) fetch this GameScore based on it's objectId alone.
//: Asynchronously (preferred way) fetch this GameScore based on it is objectId alone.
scoreToFetch.fetch { result in
switch result {
case .success(let fetchedScore):
Expand All @@ -284,7 +284,7 @@ scoreToFetch.fetch { result in
}
}

//: Synchronously fetch this GameScore based on it's objectId alone.
//: Synchronously fetch this GameScore based on it is objectId alone.
do {
let fetchedScore = try scoreToFetch.fetch()
print("Successfully fetched: \(fetchedScore)")
Expand All @@ -295,7 +295,7 @@ do {
//: Now we will fetch `ParseObject`'s in batch that have already been saved based on its' objectId.
let score2ToFetch = GameScore(objectId: score2ForFetchedLater?.objectId)

//: Asynchronously (preferred way) fetch GameScores based on it's objectId alone.
//: Asynchronously (preferred way) fetch GameScores based on it is objectId alone.
[scoreToFetch, score2ToFetch].fetchAll { result in
switch result {
case .success(let fetchedScores):
Expand All @@ -315,7 +315,7 @@ let score2ToFetch = GameScore(objectId: score2ForFetchedLater?.objectId)

var fetchedScore: GameScore!

//: Synchronously fetchAll GameScore's based on it's objectId's alone.
//: Synchronously fetchAll GameScore's based on it is objectId's alone.
do {
let fetchedScores = try [scoreToFetch, score2ToFetch].fetchAll()
fetchedScores.forEach { result in
Expand All @@ -331,7 +331,7 @@ do {
assertionFailure("Error fetching: \(error)")
}

//: Asynchronously (preferred way) deleteAll GameScores based on it's objectId alone.
//: Asynchronously (preferred way) deleteAll GameScores based on it is objectId alone.
[scoreToFetch, score2ToFetch].deleteAll { result in
switch result {
case .success(let deletedScores):
Expand All @@ -348,7 +348,7 @@ do {
}
}

//: Synchronously deleteAll GameScore's based on it's objectId's alone.
//: Synchronously deleteAll GameScore's based on it is objectId's alone.
//: Commented out because the async above deletes the items already.
/* do {
let fetchedScores = try [scoreToFetch, score2ToFetch].deleteAll()
Expand Down
Expand Up @@ -109,10 +109,10 @@ var savedRole: Role<User>?

//: Now we will create the Role.
guard let currentUser = User.current else {
fatalError("User currently isn't signed in")
fatalError("User currently is not signed in")
}

//: Every Role requires an ACL that can't be changed after saving.
//: Every Role requires an ACL that cannot be changed after saving.
var acl = ParseACL()
acl.setReadAccess(user: currentUser, value: true)
acl.setWriteAccess(user: currentUser, value: true)
Expand Down Expand Up @@ -312,7 +312,7 @@ let score2 = GameScore(points: 57)
print(error)
}
case .failure(let error):
print("Couldn't save scores. \(error)")
print("Could not save scores. \(error)")
}
}

Expand Down

0 comments on commit 89e5e69

Please sign in to comment.