Skip to content

feat(crashlytics): add support for Pigeon. Update iOS to Swift and An… #17467

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

Draft
wants to merge 1 commit into
base: feat-crashlytics-pigeon-support
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
AAE9D7BFA8AAA8783C2860B2 /* GoogleService-Info.plist in Sources */ = {isa = PBXBuildFile; fileRef = 864CBEC4F3EDA362F4B5B76D /* GoogleService-Info.plist */; };
BEEC41346759ADDC8685A9A4 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 627281BAE4683CE024487CCB /* Pods_Runner.framework */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -35,10 +36,13 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
35675B10B116DC277C431721 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
627281BAE4683CE024487CCB /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
85096D8D32F4E8438DDCF2CD /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
864CBEC4F3EDA362F4B5B76D /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
Expand All @@ -48,6 +52,7 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AFA8AEE0B355AE68B1E56082 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -56,6 +61,7 @@
buildActionMask = 2147483647;
files = (
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
BEEC41346759ADDC8685A9A4 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -65,10 +71,21 @@
578F13DB49C24452CA02A630 /* Pods */ = {
isa = PBXGroup;
children = (
85096D8D32F4E8438DDCF2CD /* Pods-Runner.debug.xcconfig */,
35675B10B116DC277C431721 /* Pods-Runner.release.xcconfig */,
AFA8AEE0B355AE68B1E56082 /* Pods-Runner.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
949A5E8792F1031BE00473AE /* Frameworks */ = {
isa = PBXGroup;
children = (
627281BAE4683CE024487CCB /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
Expand All @@ -88,6 +105,7 @@
97C146EF1CF9000F007C117D /* Products */,
578F13DB49C24452CA02A630 /* Pods */,
864CBEC4F3EDA362F4B5B76D /* GoogleService-Info.plist */,
949A5E8792F1031BE00473AE /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -130,13 +148,15 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
8F72F3C6E5DA89F9AF59A4AF /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
324E062721E4156B000CBB4D /* ShellScript */,
47FC71FAC0C4CF9ECE2B6F0E /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -176,7 +196,7 @@
);
mainGroup = 97C146E51CF9000F007C117D;
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */,
);
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -235,7 +255,69 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
47FC71FAC0C4CF9ECE2B6F0E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreExtension/FirebaseCoreExtension.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreInternal/FirebaseCoreInternal.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCrashlytics/FirebaseCrashlytics.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseInstallations/FirebaseInstallations.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfigInterop/FirebaseRemoteConfigInterop.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseSessions/FirebaseSessions.framework",
"${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/PromisesSwift/Promises.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreExtension.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreInternal.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCrashlytics.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseInstallations.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseRemoteConfigInterop.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseSessions.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleDataTransport.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Promises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
8F72F3C6E5DA89F9AF59A4AF /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -543,7 +625,7 @@
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = {
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -63,11 +64,13 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Pod::Spec.new do |s|
s.authors = 'The Chromium Authors'
s.source = { :path => '.' }

s.source_files = 'firebase_crashlytics/Sources/firebase_crashlytics/**/*.{swift}'
s.public_header_files = 'firebase_crashlytics/Sources/firebase_crashlytics/include/*.h'
s.source_files = 'firebase_crashlytics/Sources/firebase_crashlytics/**/*.{h,m,swift}'
s.public_header_files = 'firebase_crashlytics/Sources/firebase_crashlytics/include/*.h', 'firebase_crashlytics/Sources/firebase_crashlytics/FLTFirebaseCrashlyticsPlatformBridge.h'

s.ios.deployment_target = '13.0'
s.swift_version = '5.0'
Expand All @@ -44,8 +44,7 @@ Pod::Spec.new do |s|
s.static_framework = true
s.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\\"#{library_version}\\\" LIBRARY_NAME=\\\"flutter-fire-cls\\\"",
'DEFINES_MODULE' => 'YES',
'SWIFT_OBJC_BRIDGING_HEADER' => 'firebase_crashlytics/Sources/firebase_crashlytics/FirebaseCrashlytics-Bridging-Header.h'
'DEFINES_MODULE' => 'YES'
}
s.user_target_xcconfig = { 'DEBUG_INFORMATION_FORMAT' => 'dwarf-with-dsym' }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// FLTFirebaseCrashlyticsPlatformBridge.h
// firebase_crashlytics
//
// Objective-C bridge for accessing private Firebase Crashlytics APIs
//

@import Foundation;
@import FirebaseCrashlytics;

NS_ASSUME_NONNULL_BEGIN

@interface FLTFirebaseCrashlyticsPlatformBridge : NSObject

/// Setup platform information using private APIs
+ (void)setupPlatformInfo;

/// Record an on-demand exception using private APIs
+ (void)recordOnDemandException:(FIRExceptionModel *)exception;

/// Configure an exception model with private properties
+ (void)configureExceptionModel:(FIRExceptionModel *)exception
isFatal:(BOOL)isFatal
onDemand:(BOOL)onDemand;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// FLTFirebaseCrashlyticsPlatformBridge.m
// firebase_crashlytics
//
// Objective-C bridge implementation for accessing private Firebase Crashlytics APIs
//

#import "FLTFirebaseCrashlyticsPlatformBridge.h"
#import "include/Crashlytics_Platform.h"
#import "include/ExceptionModel_Platform.h"

@implementation FLTFirebaseCrashlyticsPlatformBridge

+ (void)setupPlatformInfo {
// Use private APIs to set platform information
[[FIRCrashlytics crashlytics] setDevelopmentPlatformName:@"Flutter"];
[[FIRCrashlytics crashlytics] setDevelopmentPlatformVersion:@"-1"];
}

+ (void)recordOnDemandException:(FIRExceptionModel *)exception {
// Use public API method - Swift record(onDemandException:) becomes record: in Objective-C
[[FIRCrashlytics crashlytics] record:exception];
}

+ (void)configureExceptionModel:(FIRExceptionModel *)exception
isFatal:(BOOL)isFatal
onDemand:(BOOL)onDemand {
// Use private properties to configure exception
exception.isFatal = isFatal;
exception.onDemand = onDemand;
}

@end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,23 @@ private let kCrashlyticsArgumentDidCrashOnPreviousExecution = "didCrashOnPreviou

@objc(FirebaseCrashlyticsPlugin)
public class FirebaseCrashlyticsPlugin: NSObject, FLTFirebasePluginProtocol, CrashlyticsHostApi {

private override init() {
super.init()
// Register with the Flutter Firebase plugin registry.
FLTFirebasePluginRegistry.sharedInstance().register(self)
Crashlytics.crashlytics().setValue("Flutter", forKey: "developmentPlatformName")
Crashlytics.crashlytics().setValue("-1", forKey: "developmentPlatformVersion")

// Use Objective-C bridge to access private APIs
FLTFirebaseCrashlyticsPlatformBridge.setupPlatformInfo()
}


// MARK: - Singleton

// Returns a singleton instance of the Firebase Crashlytics plugin.
public static let sharedInstance = FirebaseCrashlyticsPlugin()

// MARK: - FlutterPlugin

@objc
public static func register(with registrar: FlutterPluginRegistrar) {
let binaryMessenger: FlutterBinaryMessenger
Expand All @@ -64,7 +63,7 @@ public class FirebaseCrashlyticsPlugin: NSObject, FLTFirebasePluginProtocol, Cra
#endif
CrashlyticsHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: sharedInstance)
}

func recordError(arguments: [String: Any?],
completion: @escaping (Result<Void, any Error>) -> Void) {
let reason = arguments[kCrashlyticsArgumentReason] as? String
Expand Down Expand Up @@ -114,12 +113,19 @@ public class FirebaseCrashlyticsPlugin: NSObject, FLTFirebasePluginProtocol, Cra

let exception = ExceptionModel(name: "FlutterError", reason: finalReason)
exception.stackTrace = frames
exception.onDemand = true
exception.isFatal = fatal

// Use Objective-C bridge to configure private properties and record
FLTFirebaseCrashlyticsPlatformBridge.configureExceptionModel(
exception,
isFatal: fatal,
onDemand: true
)

if fatal {
Crashlytics.crashlytics().record(onDemandExceptionModel: exception)
// Use private API via bridge
FLTFirebaseCrashlyticsPlatformBridge.recordOnDemandException(exception)
} else {
// Use public API
Crashlytics.crashlytics().record(exceptionModel: exception)
}
completion(.success(()))
Expand Down Expand Up @@ -260,12 +266,19 @@ public class FirebaseCrashlyticsPlugin: NSObject, FLTFirebasePluginProtocol, Cra

let exception = ExceptionModel(name: "FlutterError", reason: finalReason)
exception.stackTrace = frames
exception.onDemand = true
exception.isFatal = fatal

// Use Objective-C bridge to configure private properties and record
FLTFirebaseCrashlyticsPlatformBridge.configureExceptionModel(
exception,
isFatal: fatal,
onDemand: true
)

if fatal {
Crashlytics.crashlytics().record(onDemandExceptionModel: exception)
// Use private API via bridge
FLTFirebaseCrashlyticsPlatformBridge.recordOnDemandException(exception)
} else {
// Use public API
Crashlytics.crashlytics().record(exceptionModel: exception)
}
result.success(nil)
Expand Down
Loading