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

Firebase 3 + Naming Collisions fix #21

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 61 additions & 41 deletions Nora.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@
07E554301E96B33C00D81D9B /* NoraTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07E5542F1E96B33C00D81D9B /* NoraTests.swift */; };
07E554321E96B33C00D81D9B /* Nora.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B062C6CF1E946B59006C3CB8 /* Nora.framework */; };
4C3DA810DFDAB2B7494B5061 /* Pods_Nora.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4C9489816D143B076B1BA00 /* Pods_Nora.framework */; };
B0602A3C1E98F03D0087BBD9 /* DatabaseProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A321E98F03D0087BBD9 /* DatabaseProvider.swift */; };
B0602A3D1E98F03D0087BBD9 /* StorageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A331E98F03D0087BBD9 /* StorageProvider.swift */; };
B0602A3E1E98F03D0087BBD9 /* FirebaseTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A341E98F03D0087BBD9 /* FirebaseTarget.swift */; };
B0602A3F1E98F03D0087BBD9 /* FirebaseTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A351E98F03D0087BBD9 /* FirebaseTask.swift */; };
B0602A401E98F03D0087BBD9 /* DatabaseRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A361E98F03D0087BBD9 /* DatabaseRequest.swift */; };
B0602A411E98F03D0087BBD9 /* DatabaseResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A371E98F03D0087BBD9 /* DatabaseResponse.swift */; };
B0602A421E98F03D0087BBD9 /* StorageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A381E98F03D0087BBD9 /* StorageRequest.swift */; };
B0602A431E98F03D0087BBD9 /* StorageResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A391E98F03D0087BBD9 /* StorageResponse.swift */; };
B0602A441E98F03D0087BBD9 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A3A1E98F03D0087BBD9 /* Result.swift */; };
B0602A451E98F03D0087BBD9 /* NoraError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A3B1E98F03D0087BBD9 /* NoraError.swift */; };
5D97DDA21F13989200C5926F /* DatabaseProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD981F13989200C5926F /* DatabaseProvider.swift */; };
5D97DDA31F13989200C5926F /* DatabaseProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD981F13989200C5926F /* DatabaseProvider.swift */; };
5D97DDA41F13989200C5926F /* DatabaseRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD991F13989200C5926F /* DatabaseRequest.swift */; };
5D97DDA51F13989200C5926F /* DatabaseRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD991F13989200C5926F /* DatabaseRequest.swift */; };
5D97DDA61F13989200C5926F /* DatabaseResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9A1F13989200C5926F /* DatabaseResponse.swift */; };
5D97DDA71F13989200C5926F /* DatabaseResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9A1F13989200C5926F /* DatabaseResponse.swift */; };
5D97DDA81F13989200C5926F /* FirebaseTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9B1F13989200C5926F /* FirebaseTarget.swift */; };
5D97DDA91F13989200C5926F /* FirebaseTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9B1F13989200C5926F /* FirebaseTarget.swift */; };
5D97DDAA1F13989200C5926F /* FirebaseTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9C1F13989200C5926F /* FirebaseTask.swift */; };
5D97DDAB1F13989200C5926F /* FirebaseTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9C1F13989200C5926F /* FirebaseTask.swift */; };
5D97DDAC1F13989200C5926F /* NoraError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9D1F13989200C5926F /* NoraError.swift */; };
5D97DDAD1F13989200C5926F /* NoraError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9D1F13989200C5926F /* NoraError.swift */; };
5D97DDAE1F13989200C5926F /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9E1F13989200C5926F /* Result.swift */; };
5D97DDAF1F13989200C5926F /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9E1F13989200C5926F /* Result.swift */; };
5D97DDB01F13989200C5926F /* StorageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9F1F13989200C5926F /* StorageProvider.swift */; };
5D97DDB11F13989200C5926F /* StorageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9F1F13989200C5926F /* StorageProvider.swift */; };
5D97DDB21F13989200C5926F /* StorageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DDA01F13989200C5926F /* StorageRequest.swift */; };
5D97DDB31F13989200C5926F /* StorageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DDA01F13989200C5926F /* StorageRequest.swift */; };
5D97DDB41F13989200C5926F /* StorageResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DDA11F13989200C5926F /* StorageResponse.swift */; };
5D97DDB51F13989200C5926F /* StorageResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DDA11F13989200C5926F /* StorageResponse.swift */; };
B062C6E01E946B59006C3CB8 /* Nora.h in Headers */ = {isa = PBXBuildFile; fileRef = B062C6D21E946B59006C3CB8 /* Nora.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */

Expand All @@ -41,16 +51,16 @@
2A493DF63E18ED29F60987EC /* Pods-NoraTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NoraTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-NoraTests/Pods-NoraTests.debug.xcconfig"; sourceTree = "<group>"; };
47BBF9BAF2B1F6B0AE961F4B /* Pods-NoraTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NoraTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-NoraTests/Pods-NoraTests.release.xcconfig"; sourceTree = "<group>"; };
5C9D2F34406916531BC82016 /* Pods_NoraTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NoraTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B0602A321E98F03D0087BBD9 /* DatabaseProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseProvider.swift; sourceTree = "<group>"; };
B0602A331E98F03D0087BBD9 /* StorageProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageProvider.swift; sourceTree = "<group>"; };
B0602A341E98F03D0087BBD9 /* FirebaseTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseTarget.swift; sourceTree = "<group>"; };
B0602A351E98F03D0087BBD9 /* FirebaseTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseTask.swift; sourceTree = "<group>"; };
B0602A361E98F03D0087BBD9 /* DatabaseRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRequest.swift; sourceTree = "<group>"; };
B0602A371E98F03D0087BBD9 /* DatabaseResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseResponse.swift; sourceTree = "<group>"; };
B0602A381E98F03D0087BBD9 /* StorageRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageRequest.swift; sourceTree = "<group>"; };
B0602A391E98F03D0087BBD9 /* StorageResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageResponse.swift; sourceTree = "<group>"; };
B0602A3A1E98F03D0087BBD9 /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
B0602A3B1E98F03D0087BBD9 /* NoraError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoraError.swift; sourceTree = "<group>"; };
5D97DD981F13989200C5926F /* DatabaseProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseProvider.swift; sourceTree = "<group>"; };
5D97DD991F13989200C5926F /* DatabaseRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRequest.swift; sourceTree = "<group>"; };
5D97DD9A1F13989200C5926F /* DatabaseResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseResponse.swift; sourceTree = "<group>"; };
5D97DD9B1F13989200C5926F /* FirebaseTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseTarget.swift; sourceTree = "<group>"; };
5D97DD9C1F13989200C5926F /* FirebaseTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseTask.swift; sourceTree = "<group>"; };
5D97DD9D1F13989200C5926F /* NoraError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoraError.swift; sourceTree = "<group>"; };
5D97DD9E1F13989200C5926F /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
5D97DD9F1F13989200C5926F /* StorageProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageProvider.swift; sourceTree = "<group>"; };
5D97DDA01F13989200C5926F /* StorageRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageRequest.swift; sourceTree = "<group>"; };
5D97DDA11F13989200C5926F /* StorageResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageResponse.swift; sourceTree = "<group>"; };
B062C6CF1E946B59006C3CB8 /* Nora.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Nora.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B062C6D21E946B59006C3CB8 /* Nora.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Nora.h; sourceTree = "<group>"; };
B062C6D31E946B59006C3CB8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -130,16 +140,16 @@
B062C7091E947363006C3CB8 /* Sources */ = {
isa = PBXGroup;
children = (
B0602A321E98F03D0087BBD9 /* DatabaseProvider.swift */,
B0602A331E98F03D0087BBD9 /* StorageProvider.swift */,
B0602A341E98F03D0087BBD9 /* FirebaseTarget.swift */,
B0602A351E98F03D0087BBD9 /* FirebaseTask.swift */,
B0602A361E98F03D0087BBD9 /* DatabaseRequest.swift */,
B0602A371E98F03D0087BBD9 /* DatabaseResponse.swift */,
B0602A381E98F03D0087BBD9 /* StorageRequest.swift */,
B0602A391E98F03D0087BBD9 /* StorageResponse.swift */,
B0602A3A1E98F03D0087BBD9 /* Result.swift */,
B0602A3B1E98F03D0087BBD9 /* NoraError.swift */,
5D97DD981F13989200C5926F /* DatabaseProvider.swift */,
5D97DD991F13989200C5926F /* DatabaseRequest.swift */,
5D97DD9A1F13989200C5926F /* DatabaseResponse.swift */,
5D97DD9B1F13989200C5926F /* FirebaseTarget.swift */,
5D97DD9C1F13989200C5926F /* FirebaseTask.swift */,
5D97DD9D1F13989200C5926F /* NoraError.swift */,
5D97DD9E1F13989200C5926F /* Result.swift */,
5D97DD9F1F13989200C5926F /* StorageProvider.swift */,
5D97DDA01F13989200C5926F /* StorageRequest.swift */,
5D97DDA11F13989200C5926F /* StorageResponse.swift */,
);
name = Sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -230,7 +240,7 @@
};
B062C6CE1E946B59006C3CB8 = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0820;
LastSwiftMigration = 0830;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -309,23 +319,33 @@
buildActionMask = 2147483647;
files = (
07E554301E96B33C00D81D9B /* NoraTests.swift in Sources */,
5D97DDAD1F13989200C5926F /* NoraError.swift in Sources */,
5D97DDB51F13989200C5926F /* StorageResponse.swift in Sources */,
5D97DDA71F13989200C5926F /* DatabaseResponse.swift in Sources */,
5D97DDA91F13989200C5926F /* FirebaseTarget.swift in Sources */,
5D97DDB11F13989200C5926F /* StorageProvider.swift in Sources */,
5D97DDA31F13989200C5926F /* DatabaseProvider.swift in Sources */,
5D97DDA51F13989200C5926F /* DatabaseRequest.swift in Sources */,
5D97DDAF1F13989200C5926F /* Result.swift in Sources */,
5D97DDAB1F13989200C5926F /* FirebaseTask.swift in Sources */,
5D97DDB31F13989200C5926F /* StorageRequest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
B062C6CA1E946B59006C3CB8 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B0602A441E98F03D0087BBD9 /* Result.swift in Sources */,
B0602A421E98F03D0087BBD9 /* StorageRequest.swift in Sources */,
B0602A3D1E98F03D0087BBD9 /* StorageProvider.swift in Sources */,
B0602A411E98F03D0087BBD9 /* DatabaseResponse.swift in Sources */,
B0602A3F1E98F03D0087BBD9 /* FirebaseTask.swift in Sources */,
B0602A431E98F03D0087BBD9 /* StorageResponse.swift in Sources */,
B0602A3C1E98F03D0087BBD9 /* DatabaseProvider.swift in Sources */,
B0602A3E1E98F03D0087BBD9 /* FirebaseTarget.swift in Sources */,
B0602A451E98F03D0087BBD9 /* NoraError.swift in Sources */,
B0602A401E98F03D0087BBD9 /* DatabaseRequest.swift in Sources */,
5D97DDB01F13989200C5926F /* StorageProvider.swift in Sources */,
5D97DDB21F13989200C5926F /* StorageRequest.swift in Sources */,
5D97DDA41F13989200C5926F /* DatabaseRequest.swift in Sources */,
5D97DDA61F13989200C5926F /* DatabaseResponse.swift in Sources */,
5D97DDAA1F13989200C5926F /* FirebaseTask.swift in Sources */,
5D97DDA21F13989200C5926F /* DatabaseProvider.swift in Sources */,
5D97DDB41F13989200C5926F /* StorageResponse.swift in Sources */,
5D97DDAE1F13989200C5926F /* Result.swift in Sources */,
5D97DDAC1F13989200C5926F /* NoraError.swift in Sources */,
5D97DDA81F13989200C5926F /* FirebaseTarget.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
10 changes: 5 additions & 5 deletions Nora/DatabaseProvider.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import FirebaseDatabase

public typealias DatabaseCompletion = (Result<DatabaseResponse>) -> Void
public typealias TransactionBlock = (FIRMutableData) -> FIRTransactionResult
public typealias TransactionBlock = (MutableData) -> TransactionResult

public class DatabaseProvider<Target: DatabaseTarget> {

Expand Down Expand Up @@ -39,7 +39,7 @@ public class DatabaseProvider<Target: DatabaseTarget> {

private func processObserve(_ request: DatabaseQueryRequest, _ completion: @escaping DatabaseCompletion) -> UInt? {

let successMapping = { (snapshot: FIRDataSnapshot) in
let successMapping = { (snapshot: DataSnapshot) in
let result = self.convertResponseToResult(snapshot: snapshot, reference: request.query.ref, error: nil)
completion(result)
}
Expand All @@ -65,7 +65,7 @@ public class DatabaseProvider<Target: DatabaseTarget> {

private func processWrite(_ request: DatabaseRequest, _ completion: @escaping DatabaseCompletion) {

let completionBlock = { (error: Error?, reference: FIRDatabaseReference) in
let completionBlock = { (error: Error?, reference: DatabaseReference) in
let result = self.convertResponseToResult(snapshot: nil, reference: reference, error: error)
completion(result)
}
Expand Down Expand Up @@ -102,7 +102,7 @@ public class DatabaseProvider<Target: DatabaseTarget> {

private func processTransaction(_ request: DatabaseRequest, _ completion: @escaping DatabaseCompletion) {

let transactionCompletion = { (error: Error?, committed: Bool, snapshot: FIRDataSnapshot?) in
let transactionCompletion = { (error: Error?, committed: Bool, snapshot: DataSnapshot?) in
let result = self.convertResponseToResult(snapshot: snapshot, reference: request.reference, error: error, committed: committed)
completion(result)
}
Expand All @@ -114,7 +114,7 @@ public class DatabaseProvider<Target: DatabaseTarget> {
private extension DatabaseProvider {


func convertResponseToResult(snapshot: FIRDataSnapshot?, reference: FIRDatabaseReference?, error: Error?, committed: Bool? = nil) -> Result<DatabaseResponse> {
func convertResponseToResult(snapshot: DataSnapshot?, reference: DatabaseReference?, error: Error?, committed: Bool? = nil) -> Result<DatabaseResponse> {

switch (snapshot, reference, error, committed) {
case let (snapshot, .some(reference), .none, .some(committed)):
Expand Down
10 changes: 5 additions & 5 deletions Nora/DatabaseRequest.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import FirebaseDatabase

struct DatabaseRequest {

var reference: FIRDatabaseReference
var task: DatabaseTask
var transactionBlock: (FIRMutableData) -> FIRTransactionResult
var reference: DatabaseReference
var task: NRDatabaseTask
var transactionBlock: (MutableData) -> TransactionResult
var onDisconnect: Bool
var localEvents: Bool

Expand All @@ -36,8 +36,8 @@ extension DatabaseRequest {

struct DatabaseQueryRequest {

var query: FIRDatabaseQuery
var task: DatabaseTask
var query: DatabaseQuery
var task: NRDatabaseTask

}

Expand Down
8 changes: 4 additions & 4 deletions Nora/DatabaseResponse.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public protocol JSONDecodeable {

public struct DatabaseResponse {

public let snapshot: FIRDataSnapshot?
public let reference: FIRDatabaseReference
public let snapshot: DataSnapshot?
public let reference: DatabaseReference
public let isCommitted: Bool
}

public extension DatabaseResponse {

init(reference: FIRDatabaseReference, snapshot: FIRDataSnapshot? = nil, isCommitted: Bool = false) {
init(reference: DatabaseReference, snapshot: DataSnapshot? = nil, isCommitted: Bool = false) {
self.reference = reference
self.snapshot = snapshot
self.isCommitted = isCommitted
Expand Down Expand Up @@ -97,7 +97,7 @@ public extension DatabaseResponse {
var result: [[String: Any]] = []

for child in snapshot.children {
guard let snapshot = child as? FIRDataSnapshot, let json = snapshot.value as? [String: Any] else {
guard let snapshot = child as? DataSnapshot, let json = snapshot.value as? [String: Any] else {
throw NoraError.jsonMapping
}

Expand Down
Loading