Skip to content

Commit

Permalink
fix: ambiguous SDK initializer (#6)
Browse files Browse the repository at this point in the history
* fix: ambiguous SDK initializer

* bump version

* nits

* fix codecov
  • Loading branch information
cbaker6 committed Oct 23, 2022
1 parent c84b036 commit 8c58ad2
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 22 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Parse-Swift Changelog

### main
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.15.0...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift)
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.15.1...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift)
* _Contributing to this repo? Add info about your change here to be included in the next release_

### 4.15.1
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.15.0...4.15.1), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/4.15.1/documentation/parseswift)

__Fixes__
- Fixed ambigous SDK initializer ([#6](https://github.com/netrecolab/Parse-Swift/pull/6)), thanks to [Corey Baker](https://github.com/cbaker6).

### 4.15.0
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.14.2...4.15.0), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/4.15.0/documentation/parseswift)

__New features__
- Addressed an issue that prevented updating ParseObjects with saveAll ([#2](https://github.com/netrecolab/Parse-Swift/pull/2)), thanks to [Corey Baker](https://github.com/cbaker6).
- Refactored masterKey->primaryKey due to insensitive language ([#2](https://github.com/netrecolab/Parse-Swift/pull/2)), thanks to [Corey Baker](https://github.com/cbaker6).

### 4.14.2
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/4.14.1...4.14.2), [Documentation](https://swiftpackageindex.com/parse-community/Parse-Swift/4.14.2/documentation/parseswift)
Expand Down
20 changes: 8 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ If you are not familiar with Pull Requests and want to know more about them, you

## Contributing

Before you start to code, please open a [new issue](https://github.com/parse-community/Parse-Swift/issues/new/choose) to describe your idea, or search for and continue the discussion in an [existing issue](https://github.com/parse-community/Parse-Swift/issues).
Before you start to code, please open a [new issue](https://github.com/netreconlab/Parse-Swift/issues/new/choose) to describe your idea, or search for and continue the discussion in an [existing issue](https://github.com/netreconlab/Parse-Swift/issues).

> ⚠️ Please do not post a security vulnerability on GitHub or in the Parse Community Forum. Instead, follow the [Parse Community Security Policy](https://github.com/parse-community/parse-server/security/policy).
> ⚠️ Please do not post a security vulnerability on GitHub. Instead, follow the [Security Policy](https://github.com/netreconlab/parse-server/security/policy).
Please completely fill out any templates to provide essential information about your new feature or the bug you discovered.

Together we will plan out the best conceptual approach for your contribution, so that your and our time is invested in the best possible approach. The discussion often reveals how to leverage existing features of ParseSwift SDK to reach your goal with even less effort and in a more sustainable way.

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 – do not hesitate to ask for help!
Whether this is your first contribution or you are already an experienced contributor, do not hesitate to ask for help!

## Why Contributing?

Expand All @@ -54,10 +54,10 @@ Most importantly, with every contribution you improve your skills so that future

### Setting up your local machine

* [Fork](https://github.com/parse-community/Parse-Swift) this project and clone the fork on to your local machine:
* [Fork](https://github.com/netreconlab/Parse-Swift) this project and clone the fork on to your local machine:

```sh
$ git clone https://github.com/parse-community/Parse-Swift
$ git clone https://github.com/netreconlab/Parse-Swift
$ cd Parse-Swift # go into the clone directory
```

Expand All @@ -69,15 +69,15 @@ $ brew install swiftlint

### Swift Playgrounds

Any feature additions should work with a real Parse Server. You can experiment with features in the ParseSwift SDK by modifying the [ParseSwift Playground files](https://github.com/parse-community/Parse-Swift/tree/main/ParseSwift.playground/Pages). It is recommended to make sure your ParseSwift workspace in Xcode is set to build for `ParseSwift (macOS)` framework when using Swift Playgrounds. To configure the playgounds, you can do one of the following:
Any feature additions should work with a real Parse Server. You can experiment with features in the ParseSwift SDK by modifying the [ParseSwift Playground files](https://github.com/netreconlab/Parse-Swift/tree/main/ParseSwift.playground/Pages). It is recommended to make sure your ParseSwift workspace in Xcode is set to build for `ParseSwift (macOS)` framework when using Swift Playgrounds. To configure the playgounds, you can do one of the following:

* Use the pre-configured parse-server in [this repo](https://github.com/netreconlab/parse-hipaa/tree/parse-swift) which comes with docker compose files (`docker-compose up` gives you a working server) configured to connect with the ParseSwift Playgrounds. The docker comes with [Parse Dashboard](https://github.com/parse-community/parse-dashboard) and can be used with MongoDB or PostgreSQL.
* Configure the ParseSwift Playgrounds to work with your own Parse Server by editing the configuation in [Common.swift](https://github.com/parse-community/Parse-Swift/blob/e9ba846c399257100b285d25d2bd055628b13b4b/ParseSwift.playground/Sources/Common.swift#L4-L19).
* Configure the ParseSwift Playgrounds to work with your own Parse Server by editing the configuation in [Common.swift](https://github.com/netreconlab/Parse-Swift/blob/e9ba846c399257100b285d25d2bd055628b13b4b/ParseSwift.playground/Sources/Common.swift#L4-L19).

### Please Do's

* Take testing seriously! Aim to increase the test coverage with every pull request
* Add/modify test files for the code you are working on in [ParseSwiftTests](https://github.com/parse-community/Parse-Swift/tree/main/Tests/ParseSwiftTests)
* Add/modify test files for the code you are working on in [ParseSwiftTests](https://github.com/netreconlab/Parse-Swift/tree/main/Tests/ParseSwiftTests)
* Run the tests for the file you are working on using Xcode
* Run the tests for the whole project to make sure the code passes all tests. This can be done by running the tests in Xcode
* Address all errors and warnings your fixes introduce as the ParseSwift SDK should have zero warnings
Expand Down Expand Up @@ -120,7 +120,3 @@ Currently, we are not making use of the commit _scope_, which would be written a
## Evolution

The ParseSwift SDK is not a port of the [Parse-SDK-iOS-OSX SDK](https://github.com/parse-community/Parse-SDK-iOS-OSX) and though some of it may feel familiar, it is not backwards compatible and is designed using [protocol oriented programming (POP) and value types](https://www.pluralsight.com/guides/protocol-oriented-programming-in-swift) instead of OOP and reference types. You can learn more about POP by watching [this](https://developer.apple.com/videos/play/wwdc2015/408/) or [that](https://developer.apple.com/videos/play/wwdc2016/419/) videos from previous WWDC's. Please see [this thread](https://github.com/parse-community/Parse-Swift/issues/3) for a detailed discussion about the intended evolution of this SDK.

## Code of Conduct

This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/parse-community/.github/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to honor this code.
2 changes: 1 addition & 1 deletion ParseSwift-macOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 Parse Community. All rights reserved.</string>
<string>Copyright © 2022 Network Reconnaissance Lab. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
6 changes: 3 additions & 3 deletions Sources/ParseSwift/Parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public func initialize(
public func initialize(
applicationId: String,
clientKey: String? = nil,
masterKey: String? = nil,
masterKey: String,
serverURL: URL,
liveQueryServerURL: URL? = nil,
requiringCustomObjectIds: Bool = false,
Expand Down Expand Up @@ -429,7 +429,7 @@ public func initialize(
) {
initialize(applicationId: applicationId,
clientKey: clientKey,
masterKey: masterKey,
primaryKey: masterKey,
serverURL: serverURL,
liveQueryServerURL: liveQueryServerURL,
requiringCustomObjectIds: allowingCustomObjectIds,
Expand Down Expand Up @@ -523,7 +523,7 @@ public func initialize(
) {
var configuration = ParseConfiguration(applicationId: applicationId,
clientKey: clientKey,
masterKey: masterKey,
primaryKey: masterKey,
serverURL: serverURL,
liveQueryServerURL: liveQueryServerURL,
requiringCustomObjectIds: allowingCustomObjectIds,
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/ParseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

enum ParseConstants {
static let sdk = "swift"
static let version = "4.14.2"
static let version = "4.15.1"
static let fileManagementDirectory = "parse/"
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
static let fileManagementLibraryDirectory = "Library/"
Expand Down
6 changes: 3 additions & 3 deletions Sources/ParseSwift/Types/ParseConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public struct ParseConfiguration {
@available(*, deprecated, message: "Change: masterKey->primaryKey.")
public init(applicationId: String,
clientKey: String? = nil,
masterKey: String? = nil,
masterKey: String,
webhookKey: String? = nil,
serverURL: URL,
liveQueryServerURL: URL? = nil,
Expand Down Expand Up @@ -374,7 +374,7 @@ public struct ParseConfiguration {
URLCredential?) -> Void) -> Void)? = nil) {
self.init(applicationId: applicationId,
clientKey: clientKey,
masterKey: masterKey,
primaryKey: masterKey,
webhookKey: webhookKey,
serverURL: serverURL,
liveQueryServerURL: liveQueryServerURL,
Expand Down Expand Up @@ -467,7 +467,7 @@ public struct ParseConfiguration {
URLCredential?) -> Void) -> Void)? = nil) {
self.init(applicationId: applicationId,
clientKey: clientKey,
masterKey: masterKey,
primaryKey: masterKey,
webhookKey: webhookKey,
serverURL: serverURL,
liveQueryServerURL: liveQueryServerURL,
Expand Down
32 changes: 32 additions & 0 deletions Tests/ParseSwiftTests/InitializeSDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,38 @@ class InitializeSDKTests: XCTestCase {
XCTAssertNotNil(Parse.sessionDelegate.authentication)
ParseSwift.updateAuthentication(nil)
XCTAssertNil(Parse.sessionDelegate.authentication)

let configuration3 = ParseConfiguration(applicationId: "applicationId",
clientKey: "clientKey",
masterKey: "primaryKey",
serverURL: url) { (_, credential) in
credential(.performDefaultHandling, nil)
}
ParseSwift.initialize(configuration: configuration3)
XCTAssertNotNil(Parse.sessionDelegate.authentication)
ParseSwift.updateAuthentication(nil)
XCTAssertNil(Parse.sessionDelegate.authentication)

ParseSwift.initialize(applicationId: "applicationId",
clientKey: "clientKey",
masterKey: "primaryKey",
serverURL: url) { (_, credential) in
credential(.performDefaultHandling, nil)
}
XCTAssertNotNil(Parse.sessionDelegate.authentication)
ParseSwift.updateAuthentication(nil)
XCTAssertNil(Parse.sessionDelegate.authentication)

ParseSwift.initialize(applicationId: "applicationId",
clientKey: "clientKey",
masterKey: "primaryKey",
serverURL: url,
migratingFromObjcSDK: false) { (_, credential) in
credential(.performDefaultHandling, nil)
}
XCTAssertNotNil(Parse.sessionDelegate.authentication)
ParseSwift.updateAuthentication(nil)
XCTAssertNil(Parse.sessionDelegate.authentication)
}

#if !os(Linux) && !os(Android) && !os(Windows)
Expand Down

0 comments on commit 8c58ad2

Please sign in to comment.