Procházet zdrojové kódy

Cherry pick GDT changes for 6.8.0 and increment versions (#3770)

Michael Haney před 6 roky
rodič
revize
fbf91f668d

+ 1 - 1
GoogleDataTransport.podspec

@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
   s.name             = 'GoogleDataTransport'
-  s.version          = '1.1.3'
+  s.version          = '1.2.0'
   s.summary          = 'Google iOS SDK data transport.'
 
   s.description      = <<-DESC

+ 3 - 0
GoogleDataTransport/CHANGELOG.md

@@ -1,3 +1,6 @@
+# v1.2.0
+- Removes all NSAsserts in favor of custom asserts. (#3747)
+
 # v1.1.3
 - Wrap decoding in GDTUploadCoordinator in a try catch. (#3676)
 

+ 2 - 2
GoogleDataTransport/GDTLibrary/GDTAssert.m

@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-#import "GDTLibrary/Private/GDTAssert.h"
+#import "GDTLibrary/Public/GDTAssert.h"
 
-GDTAssertionBlock GDTAssertionBlockToRunInsteadOfNSAssert(void) {
+GDTAssertionBlock GDTAssertionBlockToRunInstead(void) {
   // This class is only compiled in by unit tests, and this should fail quickly in optimized builds.
   Class GDTAssertClass = NSClassFromString(@"GDTAssertHelper");
   if (__builtin_expect(!!GDTAssertClass, 0)) {

+ 4 - 1
GoogleDataTransport/GDTLibrary/GDTEvent.m

@@ -16,9 +16,9 @@
 
 #import <GoogleDataTransport/GDTEvent.h>
 
+#import <GoogleDataTransport/GDTAssert.h>
 #import <GoogleDataTransport/GDTStoredEvent.h>
 
-#import "GDTLibrary/Private/GDTAssert.h"
 #import "GDTLibrary/Private/GDTEvent_Private.h"
 
 @implementation GDTEvent
@@ -26,6 +26,9 @@
 - (instancetype)initWithMappingID:(NSString *)mappingID target:(NSInteger)target {
   GDTAssert(mappingID.length > 0, @"Please give a valid mapping ID");
   GDTAssert(target > 0, @"A target cannot be negative or 0");
+  if (mappingID == nil || mappingID.length == 0 || target <= 0) {
+    return nil;
+  }
   self = [super init];
   if (self) {
     _mappingID = mappingID;

+ 4 - 2
GoogleDataTransport/GDTLibrary/GDTPlatform.m

@@ -16,6 +16,8 @@
 
 #import <GoogleDataTransport/GDTPlatform.h>
 
+#import <GoogleDataTransport/GDTAssert.h>
+
 const GDTBackgroundIdentifier GDTBackgroundIdentifierInvalid = 0;
 
 NSString *const kGDTApplicationDidEnterBackgroundNotification =
@@ -40,8 +42,8 @@ BOOL GDTReachabilityFlagsContainWWAN(SCNetworkReachabilityFlags flags) {
 + (void)load {
 #if TARGET_OS_IOS || TARGET_OS_TV
   // If this asserts, please file a bug at https://github.com/firebase/firebase-ios-sdk/issues.
-  NSAssert(GDTBackgroundIdentifierInvalid == UIBackgroundTaskInvalid,
-           @"GDTBackgroundIdentifierInvalid and UIBackgroundTaskInvalid should be the same.");
+  GDTFatalAssert(GDTBackgroundIdentifierInvalid == UIBackgroundTaskInvalid,
+                 @"GDTBackgroundIdentifierInvalid and UIBackgroundTaskInvalid should be the same.");
 #endif
   [self sharedApplication];
 }

+ 5 - 1
GoogleDataTransport/GDTLibrary/GDTStorage.m

@@ -17,12 +17,12 @@
 #import "GDTLibrary/Private/GDTStorage.h"
 #import "GDTLibrary/Private/GDTStorage_Private.h"
 
+#import <GoogleDataTransport/GDTAssert.h>
 #import <GoogleDataTransport/GDTConsoleLogger.h>
 #import <GoogleDataTransport/GDTLifecycle.h>
 #import <GoogleDataTransport/GDTPrioritizer.h>
 #import <GoogleDataTransport/GDTStoredEvent.h>
 
-#import "GDTLibrary/Private/GDTAssert.h"
 #import "GDTLibrary/Private/GDTEvent_Private.h"
 #import "GDTLibrary/Private/GDTRegistrar_Private.h"
 #import "GDTLibrary/Private/GDTUploadCoordinator.h"
@@ -74,6 +74,10 @@ static NSString *GDTStoragePath() {
 }
 
 - (void)storeEvent:(GDTEvent *)event {
+  if (event == nil) {
+    return;
+  }
+
   [self createEventDirectoryIfNotExists];
 
   __block GDTBackgroundIdentifier bgID = GDTBackgroundIdentifierInvalid;

+ 1 - 1
GoogleDataTransport/GDTLibrary/GDTTransformer.m

@@ -17,11 +17,11 @@
 #import "GDTLibrary/Private/GDTTransformer.h"
 #import "GDTLibrary/Private/GDTTransformer_Private.h"
 
+#import <GoogleDataTransport/GDTAssert.h>
 #import <GoogleDataTransport/GDTConsoleLogger.h>
 #import <GoogleDataTransport/GDTEventTransformer.h>
 #import <GoogleDataTransport/GDTLifecycle.h>
 
-#import "GDTLibrary/Private/GDTAssert.h"
 #import "GDTLibrary/Private/GDTStorage.h"
 
 @implementation GDTTransformer

+ 6 - 3
GoogleDataTransport/GDTLibrary/GDTTransport.m

@@ -17,10 +17,10 @@
 #import <GoogleDataTransport/GDTTransport.h>
 #import "GDTLibrary/Private/GDTTransport_Private.h"
 
+#import <GoogleDataTransport/GDTAssert.h>
 #import <GoogleDataTransport/GDTClock.h>
 #import <GoogleDataTransport/GDTEvent.h>
 
-#import "GDTLibrary/Private/GDTAssert.h"
 #import "GDTLibrary/Private/GDTTransformer.h"
 
 @implementation GDTTransport
@@ -28,10 +28,13 @@
 - (instancetype)initWithMappingID:(NSString *)mappingID
                      transformers:(nullable NSArray<id<GDTEventTransformer>> *)transformers
                            target:(NSInteger)target {
+  GDTAssert(mappingID.length > 0, @"A mapping ID cannot be nil or empty");
+  GDTAssert(target > 0, @"A target cannot be negative or 0");
+  if (mappingID == nil || mappingID.length == 0 || target <= 0) {
+    return nil;
+  }
   self = [super init];
   if (self) {
-    GDTAssert(mappingID.length > 0, @"A mapping ID cannot be nil or empty");
-    GDTAssert(target > 0, @"A target cannot be negative or 0");
     _mappingID = mappingID;
     _transformers = transformers;
     _target = target;

+ 1 - 1
GoogleDataTransport/GDTLibrary/GDTUploadCoordinator.m

@@ -16,10 +16,10 @@
 
 #import "GDTLibrary/Private/GDTUploadCoordinator.h"
 
+#import <GoogleDataTransport/GDTAssert.h>
 #import <GoogleDataTransport/GDTClock.h>
 #import <GoogleDataTransport/GDTConsoleLogger.h>
 
-#import "GDTLibrary/Private/GDTAssert.h"
 #import "GDTLibrary/Private/GDTReachability.h"
 #import "GDTLibrary/Private/GDTRegistrar_Private.h"
 #import "GDTLibrary/Private/GDTStorage.h"

+ 0 - 54
GoogleDataTransport/GDTLibrary/Private/GDTAssert.h

@@ -1,54 +0,0 @@
-/*
- * Copyright 2019 Google
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#import <Foundation/Foundation.h>
-
-/** A block type that could be run instead of NSAssert. No return type, no params. */
-typedef void (^GDTAssertionBlock)(void);
-
-/** Returns the result of executing a soft-linked method present in unit tests that allows a block
- * to be run in lieu of a call to NSAssert. This helps ameliorate issues with catching exceptions
- * that occur on a dispatch_queue.
- *
- * @return A block that can be run instead of calling NSAssert, or nil.
- */
-FOUNDATION_EXPORT GDTAssertionBlock _Nullable GDTAssertionBlockToRunInsteadOfNSAssert(void);
-
-#if !defined(NS_BLOCK_ASSERTIONS)
-
-/** Asserts using NSAssert, unless a block was specified to be run instead.
- *
- * @param condition The condition you'd expect to be YES.
- */
-#define GDTAssert(condition, ...)                                                   \
-  do {                                                                              \
-    if (__builtin_expect(!(condition), 0)) {                                        \
-      GDTAssertionBlock assertionBlock = GDTAssertionBlockToRunInsteadOfNSAssert(); \
-      if (assertionBlock) {                                                         \
-        assertionBlock();                                                           \
-      } else {                                                                      \
-        NSAssert(condition, __VA_ARGS__);                                           \
-      }                                                                             \
-    }                                                                               \
-  } while (0);
-
-#else
-
-#define GDTAssert(condition, ...) \
-  do {                            \
-  } while (0);
-
-#endif  // !defined(NS_BLOCK_ASSERTIONS)

+ 91 - 0
GoogleDataTransport/GDTLibrary/Public/GDTAssert.h

@@ -0,0 +1,91 @@
+/*
+ * Copyright 2019 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import <GoogleDataTransport/GDTConsoleLogger.h>
+
+/** A block type that could be run instead of normal assertion logging. No return type, no params.
+ */
+typedef void (^GDTAssertionBlock)(void);
+
+/** Returns the result of executing a soft-linked method present in unit tests that allows a block
+ * to be run instead of normal assertion logging. This helps ameliorate issues with catching
+ * exceptions that occur on a dispatch_queue.
+ *
+ * @return A block that can be run instead of normal assert printing.
+ */
+FOUNDATION_EXPORT GDTAssertionBlock _Nullable GDTAssertionBlockToRunInstead(void);
+
+#if defined(NS_BLOCK_ASSERTIONS)
+
+#define GDTAssert(condition, ...) \
+  do {                            \
+  } while (0);
+
+#define GDTFatalAssert(condition, ...) \
+  do {                                 \
+  } while (0);
+
+#else  // defined(NS_BLOCK_ASSERTIONS)
+
+/** Asserts using a console log, unless a block was specified to be run instead.
+ *
+ * @param condition The condition you'd expect to be YES.
+ */
+#define GDTAssert(condition, ...)                                                          \
+  do {                                                                                     \
+    if (__builtin_expect(!(condition), 0)) {                                               \
+      GDTAssertionBlock assertionBlock = GDTAssertionBlockToRunInstead();                  \
+      if (assertionBlock) {                                                                \
+        assertionBlock();                                                                  \
+      } else {                                                                             \
+        __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS                                                \
+        NSString *__assert_file__ = [NSString stringWithUTF8String:__FILE__];              \
+        __assert_file__ = __assert_file__ ? __assert_file__ : @"<Unknown File>";           \
+        GDTLogError(GDTMCEGeneralError, @"Assertion failed (%@:%d): %s,", __assert_file__, \
+                    __LINE__, ##__VA_ARGS__);                                              \
+        __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS                                                 \
+      }                                                                                    \
+    }                                                                                      \
+  } while (0);
+
+/** Asserts by logging to the console and throwing an exception if NS_BLOCK_ASSERTIONS is not
+ * defined.
+ *
+ * @param condition The condition you'd expect to be YES.
+ */
+#define GDTFatalAssert(condition, ...)                                                  \
+  do {                                                                                  \
+    __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS                                                 \
+    if (__builtin_expect(!(condition), 0)) {                                            \
+      NSString *__assert_file__ = [NSString stringWithUTF8String:__FILE__];             \
+      __assert_file__ = __assert_file__ ? __assert_file__ : @"<Unknown File>";          \
+      GDTLogError(GDTMCEFatalAssertion,                                                 \
+                  @"Fatal assertion encountered, please open an issue at "              \
+                   "https://github.com/firebase/firebase-ios-sdk/issues "               \
+                   "(%@:%d): %s,",                                                      \
+                  __assert_file__, __LINE__, ##__VA_ARGS__);                            \
+      [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd                   \
+                                                          object:self                   \
+                                                            file:__assert_file__        \
+                                                      lineNumber:__LINE__               \
+                                                     description:@"%@", ##__VA_ARGS__]; \
+    }                                                                                   \
+    __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS                                                  \
+  } while (0);
+
+#endif  // defined(NS_BLOCK_ASSERTIONS)

+ 6 - 1
GoogleDataTransport/GDTLibrary/Public/GDTConsoleLogger.h

@@ -56,7 +56,12 @@ typedef NS_ENUM(NSInteger, GDTMessageCode) {
   GDTMCETransportBytesError = 1005,
 
   /** For general purpose error messages in a dependency. */
-  GDTMCEGeneralError = 1006
+  GDTMCEGeneralError = 1006,
+
+  /** For fatal errors. Please go to https://github.com/firebase/firebase-ios-sdk/issues and open
+   * an issue if you encounter an error with this code.
+   */
+  GDTMCEFatalAssertion = 1007
 };
 
 /** */

+ 19 - 17
GoogleDataTransport/GDTTests/Integration/Helpers/GDTIntegrationTestUploader.m

@@ -16,6 +16,7 @@
 
 #import "GDTTests/Integration/Helpers/GDTIntegrationTestUploader.h"
 
+#import <GoogleDataTransport/GDTAssert.h>
 #import <GoogleDataTransport/GDTRegistrar.h>
 #import <GoogleDataTransport/GDTStoredEvent.h>
 
@@ -41,7 +42,8 @@
 }
 
 - (void)uploadPackage:(GDTUploadPackage *)package {
-  NSAssert(!_currentUploadTask, @"An upload shouldn't be initiated with another in progress.");
+  GDTFatalAssert(!_currentUploadTask,
+                 @"An upload shouldn't be initiated with another in progress.");
   NSURL *serverURL = arc4random_uniform(2) ? [_serverURL URLByAppendingPathComponent:@"log"]
                                            : [_serverURL URLByAppendingPathComponent:@"logBatch"];
   NSURLSession *session = [NSURLSession sharedSession];
@@ -54,24 +56,24 @@
   // In real usage, you'd create an instance of whatever request proto your server needs.
   for (GDTStoredEvent *event in package.events) {
     NSData *fileData = [NSData dataWithContentsOfURL:event.dataFuture.fileURL];
-    NSAssert(fileData, @"An event file shouldn't be empty");
+    GDTFatalAssert(fileData, @"An event file shouldn't be empty");
     [uploadData appendData:fileData];
   }
-  _currentUploadTask =
-      [session uploadTaskWithRequest:request
-                            fromData:uploadData
-                   completionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response,
-                                       NSError *_Nullable error) {
-                     NSLog(@"Batch upload complete.");
-                     // Remove from the prioritizer if there were no errors.
-                     NSAssert(!error, @"There should be no errors uploading events: %@", error);
-                     if (error) {
-                       [package retryDeliveryInTheFuture];
-                     } else {
-                       [package completeDelivery];
-                     }
-                     self->_currentUploadTask = nil;
-                   }];
+  _currentUploadTask = [session
+      uploadTaskWithRequest:request
+                   fromData:uploadData
+          completionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response,
+                              NSError *_Nullable error) {
+            NSLog(@"Batch upload complete.");
+            // Remove from the prioritizer if there were no errors.
+            GDTFatalAssert(!error, @"There should be no errors uploading events: %@", error);
+            if (error) {
+              [package retryDeliveryInTheFuture];
+            } else {
+              [package completeDelivery];
+            }
+            self->_currentUploadTask = nil;
+          }];
   [_currentUploadTask resume];
 }
 

+ 41 - 0
GoogleDataTransport/GDTTests/Unit/GDTAssertTest.m

@@ -0,0 +1,41 @@
+/*
+ * Copyright 2019 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#undef NS_BLOCK_ASSERTIONS
+
+#import <XCTest/XCTest.h>
+
+#import <GoogleDataTransport/GDTAssert.h>
+
+@interface GDTAssertNotBlockedTest : XCTestCase
+
+@end
+
+@implementation GDTAssertNotBlockedTest
+
+/** Tests that asserting is innocuous and doesn't throw. */
+- (void)testNonFatallyAssertingDoesntThrow {
+  GDTAssert(NO, @"test assertion");
+}
+
+/** Tests that fatally asserting throws. */
+- (void)testFatallyAssertingThrows {
+  void (^assertionBlock)(void) = ^{
+    GDTFatalAssert(NO, @"test assertion")
+  };
+  XCTAssertThrows(assertionBlock());
+}
+@end

+ 1 - 1
GoogleDataTransport/GDTTests/Unit/GDTEventTest.m

@@ -29,7 +29,7 @@
 /** Tests the designated initializer. */
 - (void)testInit {
   XCTAssertNotNil([[GDTEvent alloc] initWithMappingID:@"1" target:1]);
-  XCTAssertThrows([[GDTEvent alloc] initWithMappingID:@"" target:1]);
+  XCTAssertNil([[GDTEvent alloc] initWithMappingID:@"" target:1]);
 }
 
 /** Tests NSKeyedArchiver encoding and decoding. */

+ 1 - 1
GoogleDataTransport/GDTTests/Unit/GDTTransportTest.m

@@ -33,7 +33,7 @@
 /** Tests the default initializer. */
 - (void)testInit {
   XCTAssertNotNil([[GDTTransport alloc] initWithMappingID:@"1" transformers:nil target:1]);
-  XCTAssertThrows([[GDTTransport alloc] initWithMappingID:@"" transformers:nil target:1]);
+  XCTAssertNil([[GDTTransport alloc] initWithMappingID:@"" transformers:nil target:1]);
 }
 
 /** Tests sending a telemetry event. */

+ 3 - 3
GoogleDataTransport/GDTTests/Unit/Helpers/GDTAssertHelper.h

@@ -16,14 +16,14 @@
 
 #import <Foundation/Foundation.h>
 
-#import "GDTLibrary/Private/GDTAssert.h"
+#import "GDTLibrary/Public/GDTAssert.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
-/** Allows the setting a block to be used in the GDTAssert macro instead of a call to NSAssert. */
+/** Allows the setting a block to be used in the GDTAssert macro instead of assertion log. */
 @interface GDTAssertHelper : NSObject
 
-/** A class property that can be run instead of NSAssert. */
+/** A class property that can be run instead of normal assertion logging. */
 @property(class, nullable, nonatomic) GDTAssertionBlock assertionBlock;
 
 @end

+ 2 - 2
GoogleDataTransportCCTSupport.podspec

@@ -1,7 +1,7 @@
 
 Pod::Spec.new do |s|
   s.name             = 'GoogleDataTransportCCTSupport'
-  s.version          = '1.0.2'
+  s.version          = '1.0.3'
   s.summary          = 'Support library for the GoogleDataTransport CCT backend target.'
 
 
@@ -30,7 +30,7 @@ Support library to provide event prioritization and uploading for the GoogleData
   s.source_files = 'GoogleDataTransportCCTSupport/GDTCCTLibrary/**/*'
   s.private_header_files = 'GoogleDataTransportCCTSupport/GDTCCTLibrary/Private/*.h'
 
-  s.dependency 'GoogleDataTransport', '~> 1.1'
+  s.dependency 'GoogleDataTransport', '~> 1.2'
   s.dependency 'nanopb'
 
   header_search_paths = {

+ 6 - 0
GoogleDataTransportCCTSupport/CHANGELOG.md

@@ -1,3 +1,9 @@
+# v1.0.3
+- Remove all NSAsserts in favor of GDTAssert.
+
+# v1.0.2
+- More safely handle backgrounding.
+
 # v1.0.1
 - Removed unused fields from firebasecore.proto.
 

+ 2 - 1
GoogleDataTransportCCTSupport/GDTCCTTests/Unit/Helpers/GDTCCTEventGenerator.m

@@ -16,6 +16,7 @@
 
 #import "GDTCCTTests/Unit/Helpers/GDTCCTEventGenerator.h"
 
+#import <GoogleDataTransport/GDTAssert.h>
 #import <GoogleDataTransport/GDTTargets.h>
 
 @implementation GDTCCTEventGenerator
@@ -27,7 +28,7 @@ static volatile NSUInteger gCounter = 0;
   for (GDTStoredEvent *storedEvent in self.allGeneratedEvents) {
     NSError *error;
     [[NSFileManager defaultManager] removeItemAtURL:storedEvent.dataFuture.fileURL error:&error];
-    NSAssert(error == nil, @"There was an error deleting a temporary event file.");
+    GDTAssert(error == nil, @"There was an error deleting a temporary event file.");
   }
 }
 

+ 7 - 5
GoogleDataTransportCCTSupport/GDTCCTTests/Unit/TestServer/GDTCCTTestServer.m

@@ -16,6 +16,8 @@
 
 #import "GDTCCTTests/Unit/TestServer/GDTCCTTestServer.h"
 
+#import <GoogleDataTransport/GDTAssert.h>
+
 #import <nanopb/pb_decode.h>
 #import <nanopb/pb_encode.h>
 
@@ -50,16 +52,16 @@
 }
 
 - (void)start {
-  NSAssert(self.server.isRunning == NO, @"The server should not be already running.");
+  GDTAssert(self.server.isRunning == NO, @"The server should not be already running.");
   NSError *error;
   [self.server
       startWithOptions:@{GCDWebServerOption_Port : @0, GCDWebServerOption_BindToLocalhost : @YES}
                  error:&error];
-  NSAssert(error == nil, @"Error when starting server: %@", error);
+  GDTAssert(error == nil, @"Error when starting server: %@", error);
 }
 
 - (void)stop {
-  NSAssert(self.server.isRunning, @"The server should be running before stopping.");
+  GDTAssert(self.server.isRunning, @"The server should be running before stopping.");
   [self.server stop];
 }
 
@@ -85,7 +87,7 @@
   pb_ostream_t sizestream = PB_OSTREAM_SIZING;
   // Encode 1 time to determine the size.
   if (!pb_encode(&sizestream, gdt_cct_LogResponse_fields, &logResponse)) {
-    NSCAssert(NO, @"Error in nanopb encoding for size: %s", PB_GET_ERROR(&sizestream));
+    GDTAssert(NO, @"Error in nanopb encoding for size: %s", PB_GET_ERROR(&sizestream));
   }
 
   // Encode a 2nd time to actually get the bytes from it.
@@ -93,7 +95,7 @@
   CFMutableDataRef dataRef = CFDataCreateMutable(CFAllocatorGetDefault(), bufferSize);
   pb_ostream_t ostream = pb_ostream_from_buffer((void *)CFDataGetBytePtr(dataRef), bufferSize);
   if (!pb_encode(&sizestream, gdt_cct_LogResponse_fields, &logResponse)) {
-    NSCAssert(NO, @"Error in nanopb encoding for bytes: %s", PB_GET_ERROR(&ostream));
+    GDTAssert(NO, @"Error in nanopb encoding for bytes: %s", PB_GET_ERROR(&ostream));
   }
   CFDataSetLength(dataRef, ostream.bytes_written);
   pb_release(gdt_cct_LogResponse_fields, &logResponse);