Skip to content

Commit 783ee5b

Browse files
authored
Implement Firebase CoreDiagnostics (#3129)
* Implement CoreDiagnostics interop For use by FirebaseCore. Please pay special attention to the changes in FIRApp, I've replaced passing FIRApp in the notification with a data object that will eventually replace the same information that FIRDiagnostics extracted. * Add CoreDiagnosticsInterop to the Example Podfile * Style and xcodeproj updates * Update Podfiles that dep on FirebaseCore So that they also have a dep on FirebaseCoreDiagnosticsInterop * ran pod deintegrate to remove unintended xcodeproj changes * Fix Podfile paths * Add FCD to if_changed and travis.yml * Fix building with Firestore * Style * Whitespace * Fix a changed internal API * Make pod paths consistent * Restore connectivity_monitor_noop.cc style * Remove logging prior to [FIRApp configure] Also remove sendLogsWithServiceName:version: * style * Remove nil checks from diagnostics data * Put back some deleted symbols * Restore the sendLogsWithServiceName:version: method, but as a no-op * Restore the original version of sendLogs... * Allow an unused parameter * Remove obsolete nsnotificationcenter related stuff * Whoops, missed the header change. * Final changes to support FIRCoreDiagnostics These changes are necessary because FIRCore has a hard dep on FIRCoreDiagnostics (FIRCD) and FIRCoreDiagnosticsInterop. Components can't be used because FIRCD would need to have a hard dep on FIRCore to get access to FIRLibrary, FIRComponent, FIRComponentContainer, and FIRComponentCreationBlock and this would create a dep cycle. So, an extern has been put into the interop lib and the variable is implemented in the connector class inside of FIRCore, but it's unset. FIRCD actually sets that variable in +load, allowing use of FIRCD. FIRCD can also be removed as a dependency with no ill effect by end users setting the environment variable DISABLE_FIREBASE_DIAGNOSTICS=1 * Add nanopb and project generation infrastructure * Convert FIRCoreDiagnostics to canonical nanopb, and move to OSS. * Remove custom build steps for CoreDiagnostics * Addressing review comments * Update versions, tags, and port the relevant unit tests for FIRCD * Version and platform fixes * Fix podspec expected tags * A hack to solve a chicken-and-egg problem with pod lib linting. * Heartbeat implementation * FIRDiagnosticsDateFileStorageTests * Fix tests for non-iOS platforms * Heartbeat tests * Fix initialization. * Cleanup Installation ID. * Fix testProtoPopulation. * Merge conflict fix * Typo fix. * Remove FIRCore dep from FIRCD unit tests and move symbols to interop * Run ./scripts/style.sh * Typo * #ifdef comment * File license header. * Import FIRDiagnosticsDateFileStorage.h using relative path. * FIRDiagnostics -> FIRCoreDiagnostics * Docs syntax * Docs * Docs typo * Add shared variables to the interop lib I know this goes against the convention, but it's actually the only way to resolve this very unique problem. * Fix comment * Style * Removed lib version passing. * Remove env checking for conditional deps * Style * Address whitespace issues * Add copyright notice * Add new deps to Podfiles * Fix trailing space * Some changes to fix working in an extension. * Fix type in Podfile * GDT: begin/end background task only for iOS and TVOS applications. * Fix typo * Style * Stop sharing kFIRService strings across pods * Travis test * Change all TARGET_OS_TVOS macros to TARGET_OS_TV TARGET_OS_TVOS doesn't exist. Also macro out a UIApplication reference. * style * Update all Podfiles with deps on FIRCore * Fix trailing whitespace * Update Firestore cmake * Fix FIAM build break (#3254) * Additional cmake changes * Fix linker issue with deprecated CoreDiagnostics (#3257) * Adding more deps to cmake * Fix linker error (#3266) * Rerun only IAM tests * whitespace * No xcpretty or frameworks run * Fix typo * Revert "No xcpretty or frameworks run" This reverts commit afc1abb. * Revert "whitespace" This reverts commit fd06955. * Revert "Rerun only IAM tests" This reverts commit 98ce076. * Run travis on this branch * Add support for expanding PODS_TARGET_SRCROOT in CMake (#3267) * Fix a few things that should have been splatted but weren't * Define PODS_TARGET_SRCROOT in CMake for compatibility with CocoaPods * Compile pods we depend upon with looser settings * Rename the nanopb dependency to match what CMake actually has * Make #include <nanopb/pb.h> work Remove the old way of #include <pb.h> once we change the Firestore nanopb generator to match. * Fix warnings that fail the build * Remove typed enum and fix a comment. * Fix an import * Change a line so it's not altered by Copybara * More changes to stop copybara from altering the wrong sources * Remove trailing whitespace * Fix copybara modifying python. * Add additional field in firebasecore.proto (#3273) * Remove the dependency on interop to populate a shared variable. * style * Create travis jobs for FirebaseCoreDiagnostics (#3245) * Create travis jobs for FirebaseCoreDiagnostics And update the pod lib lints for GDT. Remove the mph-master branch before merging to master. * Add support for FIRCD to if_changed.sh * Adjust tests * Unavailable init methods should not be nullable (#3276) * Allow firestore api to work with Codable objects + ExplicitNull + Integration tests (#3261) * Convinience api for codables * Integration Tests * ExplicitNull implementation * Update to CocoaPods 1.7.3 (#3280) * Import GULLoggerLevel.h via public framework header (#3277) * Put the need to include Firestore/Source/Public in the podspec (#3288) This removes the need to munge the pods project after the fact and makes it so that customers can click through to our headers too. * Ensure Storage initializer doesn't get called (#3294) * FIROptions.appGroupID introduced (#3293) * Use a consistent set of dependencies on all platforms (#3289) * Use a consistent set of dependencies on all platforms * pod install for uniform dependencies * Store the coerced base value in the BaseMutation (#3292) * In card message: set the text color on the body text view (#3286) * In card message: set the text color on the body text view * Fix bug where card messages in test app were showing up with two of the same buttons * Revert change to text color * [docs] add missing semicolon (#3305) Add missing semicolon to code example * Add explicit Foundation import. (#3309) This is causing issues when building an XCFramework. * Pass the correct compiler flag for CoreDiagnostics. (#3312) * Pass the correct compiler flag for CoreDiagnostics. When CoreDiagnostics is open sourced, we'll need to ensure that the right compiler flag is passed. This doesn't add support for Carthage yet but allows the frameworkbuilder to pass the flag for carthage as well. An update to the zipbuilder to allow for carthage will follow shortly. * Remove accidental change. * Fix and rewrite sync_project.rb (#3296) * Fix and rewrite sync_project.rb Ever since we added multiple platforms, removing a file has been broken. This fixes that issue. Also, rewrite target synchronization to make more sense. Essentially now there's one diff between the filesystem and the groups and then an explicit diff is done between project files and target contents. * Run sync_project.rb on post-install * pod lib linting should output something every minute while running * DEBUG: This commit should be reverted * DEBUG: This commit should be reverted * DEBUG: This commit should be reverted * Remove mph-master from travis * Fix constant name conflic between old and new diagnostics (#3329) * Rename kFIRDiagnosticsHeartbeatDateFileName -> kFIRCoreDiagnosticsHeartbeatDateFileName to avoid conflicts with FIRDiagnostics. * Travis: temporary add `mph-master` to run tests. * Rempve mph-master again * Fix imports in FIRCDConnector * Fix another import * Fix yet another import * Attempt to read crashing test logs from disk * Implement printing of failed/crashed test logs. * Print only crashed tests, rmdir between runs * Revert reading crashing log changes * Write CHANGELOG for all new FIRCD associated libraries * Change all GUL deps to >= 6.2 * Revert ZipBuilder changes and do some last bits of cleanup * Remove an assertion and populate an error instead
1 parent 9c23d8c commit 783ee5b

File tree

66 files changed

+2971
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2971
-151
lines changed

CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,35 @@ podspec_framework(
230230
SPECS Logger
231231
)
232232

233+
podspec_framework(${FIREBASE_SOURCE_DIR}/GoogleDataTransport.podspec)
234+
235+
podspec_framework(${FIREBASE_SOURCE_DIR}/GoogleDataTransportCCTSupport.podspec)
236+
233237
podspec_framework(${FIREBASE_SOURCE_DIR}/FirebaseCore.podspec)
234238

239+
podspec_framework(${FIREBASE_SOURCE_DIR}/FirebaseCoreDiagnostics.podspec)
240+
241+
podspec_framework(
242+
${FIREBASE_SOURCE_DIR}/FirebaseCoreDiagnosticsInterop.podspec
243+
)
244+
245+
if(APPLE)
246+
# FirebaseCoreDiagnosticsInterop has no source files but CMake can't build
247+
# frameworks that don't have sources. Generate an inconsequential source
248+
# file so that the library can be linked.
249+
file(
250+
WRITE ${CMAKE_CURRENT_BINARY_DIR}/FirebaseCoreDiagnosticsInteropDummy.c
251+
"// generated file for header-only CMake support.
252+
__attribute__((unused))
253+
static void FirebaseCoreDiagnosticsInteropFakeSymbol() {}
254+
"
255+
)
256+
target_sources(
257+
FirebaseCoreDiagnosticsInterop
258+
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/FirebaseCoreDiagnosticsInteropDummy.c
259+
)
260+
endif()
261+
235262
podspec_framework(${FIREBASE_SOURCE_DIR}/FirebaseAuthInterop.podspec)
236263

237264
if(APPLE)

CocoapodsIntegrationTest/TestEnvironments/Cocoapods1_6_1_frameworks/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ target 'CocoapodsIntegrationTest' do
55
use_frameworks!
66

77
pod 'FirebaseCore', :path => '../'
8+
pod 'FirebaseCoreDiagnostics', :path => '../'
9+
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
810
pod 'FirebaseAuth', :path => '../'
9-
pod 'FirebaseCore', :path => '../'
1011
pod 'FirebaseDatabase', :path => '../'
1112
pod 'FirebaseDynamicLinks', :path => '../'
1213
pod 'FirebaseFirestore', :path => '../'
@@ -15,5 +16,7 @@ target 'CocoapodsIntegrationTest' do
1516
pod 'FirebaseInstanceID', :path => '../'
1617
pod 'FirebaseMessaging', :path => '../'
1718
pod 'FirebaseStorage', :path => '../'
19+
pod 'GoogleDataTransport', :path => '../'
20+
pod 'GoogleDataTransportCCTSupport', :path => '../'
1821
pod 'GoogleUtilities', :path => '../'
1922
end

CocoapodsIntegrationTest/TestEnvironments/Cocoapods1_6_1_staticLibs/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ platform :ios, '9.0'
33

44
target 'CocoapodsIntegrationTest' do
55
pod 'FirebaseCore', :path => '../'
6+
pod 'FirebaseCoreDiagnostics', :path => '../'
7+
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
68
pod 'FirebaseAuth', :path => '../'
7-
pod 'FirebaseCore', :path => '../'
89
pod 'FirebaseDatabase', :path => '../'
910
pod 'FirebaseDynamicLinks', :path => '../'
1011
pod 'FirebaseFirestore', :path => '../'
@@ -13,5 +14,7 @@ target 'CocoapodsIntegrationTest' do
1314
pod 'FirebaseInstanceID', :path => '../'
1415
pod 'FirebaseMessaging', :path => '../'
1516
pod 'FirebaseStorage', :path => '../'
17+
pod 'GoogleDataTransport', :path => '../'
18+
pod 'GoogleDataTransportCCTSupport', :path => '../'
1619
pod 'GoogleUtilities', :path => '../'
1720
end

CocoapodsIntegrationTest/TestEnvironments/Cocoapods1_7_0_frameworks/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ target 'CocoapodsIntegrationTest' do
55
use_frameworks!
66

77
pod 'FirebaseCore', :path => '../'
8+
pod 'FirebaseCoreDiagnostics', :path => '../'
9+
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
810
pod 'FirebaseAuth', :path => '../'
9-
pod 'FirebaseCore', :path => '../'
1011
pod 'FirebaseDatabase', :path => '../'
1112
pod 'FirebaseDynamicLinks', :path => '../'
1213
pod 'FirebaseFirestore', :path => '../'
@@ -15,5 +16,7 @@ target 'CocoapodsIntegrationTest' do
1516
pod 'FirebaseInstanceID', :path => '../'
1617
pod 'FirebaseMessaging', :path => '../'
1718
pod 'FirebaseStorage', :path => '../'
19+
pod 'GoogleDataTransport', :path => '../'
20+
pod 'GoogleDataTransportCCTSupport', :path => '../'
1821
pod 'GoogleUtilities', :path => '../'
1922
end

CocoapodsIntegrationTest/TestEnvironments/Cocoapods1_7_0_multiprojects_frameworks/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ target 'CocoapodsIntegrationTest' do
66
use_frameworks!
77

88
pod 'FirebaseCore', :path => '../'
9+
pod 'FirebaseCoreDiagnostics', :path => '../'
10+
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
911
pod 'FirebaseAuth', :path => '../'
10-
pod 'FirebaseCore', :path => '../'
1112
pod 'FirebaseDatabase', :path => '../'
1213
pod 'FirebaseDynamicLinks', :path => '../'
1314
pod 'FirebaseFirestore', :path => '../'
@@ -16,6 +17,8 @@ target 'CocoapodsIntegrationTest' do
1617
pod 'FirebaseInstanceID', :path => '../'
1718
pod 'FirebaseMessaging', :path => '../'
1819
pod 'FirebaseStorage', :path => '../'
20+
pod 'GoogleDataTransport', :path => '../'
21+
pod 'GoogleDataTransportCCTSupport', :path => '../'
1922
pod 'GoogleUtilities', :path => '../'
2023
end
2124

CocoapodsIntegrationTest/TestEnvironments/Cocoapods1_7_0_multiprojects_staticLibs/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ platform :ios, '9.0'
33

44
target 'CocoapodsIntegrationTest' do
55
pod 'FirebaseCore', :path => '../'
6+
pod 'FirebaseCoreDiagnostics', :path => '../'
7+
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
68
pod 'FirebaseAuth', :path => '../'
7-
pod 'FirebaseCore', :path => '../'
89
pod 'FirebaseDatabase', :path => '../'
910
pod 'FirebaseDynamicLinks', :path => '../'
1011
pod 'FirebaseFirestore', :path => '../'
@@ -13,6 +14,8 @@ target 'CocoapodsIntegrationTest' do
1314
pod 'FirebaseInstanceID', :path => '../'
1415
pod 'FirebaseMessaging', :path => '../'
1516
pod 'FirebaseStorage', :path => '../'
17+
pod 'GoogleDataTransport', :path => '../'
18+
pod 'GoogleDataTransportCCTSupport', :path => '../'
1619
pod 'GoogleUtilities', :path => '../'
1720
end
1821

CocoapodsIntegrationTest/TestEnvironments/Cocoapods1_7_0_staticLibs/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ platform :ios, '9.0'
33

44
target 'CocoapodsIntegrationTest' do
55
pod 'FirebaseCore', :path => '../'
6+
pod 'FirebaseCoreDiagnostics', :path => '../'
7+
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
68
pod 'FirebaseAuth', :path => '../'
7-
pod 'FirebaseCore', :path => '../'
89
pod 'FirebaseDatabase', :path => '../'
910
pod 'FirebaseDynamicLinks', :path => '../'
1011
pod 'FirebaseFirestore', :path => '../'
@@ -13,5 +14,7 @@ target 'CocoapodsIntegrationTest' do
1314
pod 'FirebaseInstanceID', :path => '../'
1415
pod 'FirebaseMessaging', :path => '../'
1516
pod 'FirebaseStorage', :path => '../'
17+
pod 'GoogleDataTransport', :path => '../'
18+
pod 'GoogleDataTransport', :path => '../'
1619
pod 'GoogleUtilities', :path => '../'
1720
end

Example/Auth/AuthSample/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ use_frameworks!
99
target 'AuthSample' do
1010
platform :ios, '8.0'
1111
pod 'FirebaseCore', :path => '../../../'
12+
pod 'FirebaseCoreDiagnostics', :path => '../../../'
13+
pod 'FirebaseCoreDiagnosticsInterop', :path => '../../../'
14+
pod 'GoogleDataTransport', :path => '../../../'
15+
pod 'GoogleDataTransportCCTSupport', :path => '../../../'
1216
pod 'GoogleUtilities', :path => '../../../'
1317
pod 'FirebaseAuth', :path => '../../../', :testspecs => ['unit']
14-
pod 'FirebaseCore', :path => '../../../'
1518
pod 'FirebaseInstanceID', :path => '../../..'
1619
pod 'FBSDKLoginKit'
1720
pod 'GoogleSignIn'

Example/Core/Tests/FIRAppTest.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#import "FIRTestCase.h"
1616
#import "FIRTestComponents.h"
1717

18+
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h>
19+
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsInterop.h>
20+
1821
#import <FirebaseCore/FIRAnalyticsConfiguration.h>
1922
#import <FirebaseCore/FIRAppInternal.h>
2023
#import <FirebaseCore/FIROptionsInternal.h>
@@ -262,7 +265,7 @@ - (void)testDeleteApp {
262265
- (void)testErrorForSubspecConfigurationFailure {
263266
NSError *error = [FIRApp errorForSubspecConfigurationFailureWithDomain:kFirebaseCoreErrorDomain
264267
errorCode:-38
265-
service:kFIRServiceAuth
268+
service:@"Auth"
266269
reason:@"some reason"];
267270
XCTAssertNotNil(error);
268271
XCTAssert([error.domain isEqualToString:kFirebaseCoreErrorDomain]);
@@ -632,9 +635,6 @@ - (void)testGlobalDataCollectionNoDiagnosticsSent {
632635
// Ensure configure doesn't fire a notification.
633636
[FIRApp configure];
634637

635-
NSError *error = [NSError errorWithDomain:@"com.firebase" code:42 userInfo:nil];
636-
[app sendLogsWithServiceName:@"Service" version:@"Version" error:error];
637-
638638
// The observer mock is strict and will raise an exception when an unexpected notification is
639639
// received.
640640
OCMVerifyAll(self.observerMock);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2019 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <XCTest/XCTest.h>
18+
19+
#import <FirebaseCore/FIRDiagnosticsData.h>
20+
21+
@interface FIRDiagnosticsDataTest : XCTestCase
22+
23+
@end
24+
25+
@implementation FIRDiagnosticsDataTest
26+
27+
/** Tests initialization. */
28+
- (void)testInit {
29+
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
30+
XCTAssertNotNil(data);
31+
}
32+
33+
/** Tests that -diagnosticObjects returns a valid default dictionary. */
34+
- (void)testFIRCoreDiagnosticsData {
35+
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
36+
XCTAssertNotNil(data.diagnosticObjects);
37+
XCTAssertNotNil(data.diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey]);
38+
XCTAssertNotNil(data.diagnosticObjects[kFIRCDllAppsCountKey]);
39+
XCTAssertNotNil(data.diagnosticObjects[kFIRCDFirebaseUserAgentKey]);
40+
}
41+
42+
/** Tests that setting diagnosticObjects throws. */
43+
- (void)testSettingDiagnosticObjectsThrows {
44+
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
45+
XCTAssertThrows(data.diagnosticObjects = @{});
46+
}
47+
48+
@end

0 commit comments

Comments
 (0)