aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-07-11 19:21:48 -0700
committerGravatar GitHub <noreply@github.com>2018-07-11 19:21:48 -0700
commit09c75c4fb8269d74ccfdfaccb36ea9f7519efdb5 (patch)
tree529ef668b3bea1870e2f8305e848ef3dda9f5801
parent82ef0886bf89339bfe7a1855e697e61959eeb486 (diff)
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
-rw-r--r--.travis.yml9
-rw-r--r--Firestore/CHANGELOG.md1
-rw-r--r--Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_Tests_iOS.xcscheme24
-rw-r--r--Firestore/core/src/firebase/firestore/local/local_serializer.cc32
-rw-r--r--Firestore/core/test/firebase/firestore/remote/serializer_test.cc2
-rwxr-xr-xscripts/build.sh2
6 files changed, 18 insertions, 52 deletions
diff --git a/.travis.yml b/.travis.yml
index 59ba692..934c106 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -119,6 +119,15 @@ jobs:
script:
- ./scripts/if_changed.sh ./scripts/build.sh $PROJECT $PLATFORM $METHOD
+ - stage: test
+ osx_image: xcode8.3
+ env:
+ - PROJECT=Firestore PLATFORM=iOS METHOD=xcodebuild XCODE_VERSION=8.3.3
+ before_install:
+ - ./scripts/if_changed.sh ./scripts/install_prereqs.sh
+ script:
+ - ./scripts/if_changed.sh ./scripts/build.sh $PROJECT $PLATFORM $METHOD
+
# Community-supported platforms
- stage: test
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">
</BuildableReference>
</BuildActionEntry>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "YES"
- buildForArchiving = "YES"
- buildForAnalyzing = "YES">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "54C9EDF02040E16300A969CD"
- BuildableName = "Firestore_SwiftTests_iOS.xctest"
- BlueprintName = "Firestore_SwiftTests_iOS"
- ReferencedContainer = "container:Firestore.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
@@ -52,16 +38,6 @@
ReferencedContainer = "container:Firestore.xcodeproj">
</BuildableReference>
</TestableReference>
- <TestableReference
- skipped = "NO">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "54C9EDF02040E16300A969CD"
- BuildableName = "Firestore_SwiftTests_iOS.xctest"
- BlueprintName = "Firestore_SwiftTests_iOS"
- ReferencedContainer = "container:Firestore.xcodeproj">
- </BuildableReference>
- </TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
diff --git a/Firestore/core/src/firebase/firestore/local/local_serializer.cc b/Firestore/core/src/firebase/firestore/local/local_serializer.cc
index c549604..bdb2792 100644
--- a/Firestore/core/src/firebase/firestore/local/local_serializer.cc
+++ b/Firestore/core/src/firebase/firestore/local/local_serializer.cc
@@ -79,11 +79,7 @@ std::unique_ptr<model::MaybeDocument> 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<model::NoDocument> no_document;
- std::unique_ptr<model::Document> document;
+ std::unique_ptr<model::MaybeDocument> result;
while (reader->bytes_left()) {
Tag tag = reader->ReadTag();
@@ -94,33 +90,21 @@ std::unique_ptr<model::MaybeDocument> 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<std::unique_ptr<model::Document>>(
+ result = reader->ReadNestedMessage<std::unique_ptr<model::Document>>(
[&](Reader* reader) -> std::unique_ptr<model::Document> {
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<std::unique_ptr<model::NoDocument>>(
- [&](Reader* reader) { return DecodeNoDocument(reader); });
- break;
-
+ result = reader->ReadNestedMessage<std::unique_ptr<model::NoDocument>>(
+ [&](Reader* reader) { return DecodeNoDocument(reader); });
break;
default:
@@ -129,16 +113,12 @@ std::unique_ptr<model::MaybeDocument> 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<uint8_t> bytes =
EncodeFieldValue(&serializer, FieldValue::NullValue());
v1beta1::Value proto;
diff --git a/scripts/build.sh b/scripts/build.sh
index 4d6c230..57d4010 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -84,7 +84,7 @@ case "$platform" in
iOS)
xcb_flags=(
-sdk 'iphonesimulator'
- -destination 'platform=iOS Simulator,name=iPhone 8 Plus'
+ -destination 'platform=iOS Simulator,name=iPhone 7'
)
;;