From 09c75c4fb8269d74ccfdfaccb36ea9f7519efdb5 Mon Sep 17 00:00:00 2001 From: Gil Date: Wed, 11 Jul 2018 19:21:48 -0700 Subject: Fix Firestore when compiled with Xcode 8.3 (#1519) * Add a travis stage that tests building Firestore with Xcode 8.3. * Simulate on a device available in Xcode 8 * Fix compile errors under Xcode 8.3.3 * Remove Firestore_SwiftTests_iOS from the Firestore_Tests_iOS Scheme I'll create a new target for this but in another PR. * Add an entry to CHANGELOG.md --- Firestore/CHANGELOG.md | 1 + .../xcschemes/Firestore_Tests_iOS.xcscheme | 24 ---------------- .../firebase/firestore/local/local_serializer.cc | 32 ++++------------------ .../firebase/firestore/remote/serializer_test.cc | 2 +- 4 files changed, 8 insertions(+), 51 deletions(-) (limited to 'Firestore') diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index 8bb3e60..1703777 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -3,6 +3,7 @@ atomically add and remove elements from an array field in a document. - [feature] Added `whereField(arrayContains:)` query filter to find documents where an array field contains a specific element. +- [fixed] Fixed compilation with older Xcode versions (#1517). # v0.12.5 - [changed] Internal improvements. diff --git a/Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_Tests_iOS.xcscheme b/Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_Tests_iOS.xcscheme index 03f30dc..69ebb9b 100644 --- a/Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_Tests_iOS.xcscheme +++ b/Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_Tests_iOS.xcscheme @@ -20,20 +20,6 @@ ReferencedContainer = "container:Firestore.xcodeproj"> - - - - - - - - LocalSerializer::DecodeMaybeDocument( Reader* reader) const { if (!reader->status().ok()) return nullptr; - // Initialize MaybeDocument fields to their default values. (Due to the - // 'oneof' in MaybeDocument, only one of 'no_document' or 'document' should - // ever be set.) - std::unique_ptr no_document; - std::unique_ptr document; + std::unique_ptr result; while (reader->bytes_left()) { Tag tag = reader->ReadTag(); @@ -94,33 +90,21 @@ std::unique_ptr LocalSerializer::DecodeMaybeDocument( case firestore_client_MaybeDocument_document_tag: if (!reader->RequireWireType(PB_WT_STRING, tag)) return nullptr; - // 'no_document' and 'document' are part of a oneof. The proto docs - // claim that if both are set on the wire, the last one wins. - no_document = nullptr; - // TODO(rsgowman): If multiple 'document' values are found, we should // merge them (rather than using the last one.) - document = reader->ReadNestedMessage>( + result = reader->ReadNestedMessage>( [&](Reader* reader) -> std::unique_ptr { return rpc_serializer_.DecodeDocument(reader); }); - break; case firestore_client_MaybeDocument_no_document_tag: if (!reader->RequireWireType(PB_WT_STRING, tag)) return nullptr; - // 'no_document' and 'document' are part of a oneof. The proto docs - // claim that if both are set on the wire, the last one wins. - document = nullptr; - // TODO(rsgowman): If multiple 'no_document' values are found, we should // merge them (rather than using the last one.) - no_document = - reader->ReadNestedMessage>( - [&](Reader* reader) { return DecodeNoDocument(reader); }); - break; - + result = reader->ReadNestedMessage>( + [&](Reader* reader) { return DecodeNoDocument(reader); }); break; default: @@ -129,16 +113,12 @@ std::unique_ptr LocalSerializer::DecodeMaybeDocument( } } - if (no_document) { - return no_document; - } else if (document) { - return document; - } else { + if (!result) { reader->set_status(Status(FirestoreErrorCode::DataLoss, "Invalid MaybeDocument message: Neither " "'no_document' nor 'document' fields set.")); - return nullptr; } + return result; } void LocalSerializer::EncodeDocument(Writer* writer, diff --git a/Firestore/core/test/firebase/firestore/remote/serializer_test.cc b/Firestore/core/test/firebase/firestore/remote/serializer_test.cc index fb08488..4e7b7c9 100644 --- a/Firestore/core/test/firebase/firestore/remote/serializer_test.cc +++ b/Firestore/core/test/firebase/firestore/remote/serializer_test.cc @@ -161,7 +161,7 @@ class SerializerTest : public ::testing::Test { EXPECT_EQ(status.code(), bad_status.status().code()); } - v1beta1::Value ValueProto(nullptr_t) { + v1beta1::Value ValueProto(std::nullptr_t) { std::vector bytes = EncodeFieldValue(&serializer, FieldValue::NullValue()); v1beta1::Value proto; -- cgit v1.2.3