-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jason Hu <jasonhu@google.com> Co-authored-by: Bryan Klimt <klimt@google.com>
- Loading branch information
Showing
253 changed files
with
28,697 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# v4.0.0-beta.1 | ||
|
||
This Firebase Crashlytics version includes the initial beta release of the Firebase Crashlytics SDK: | ||
|
||
- [feature] The SDK is now open-sourced. Take a look in our [GitHub repository](https://github.com/firebase/firebase-ios-sdk/tree/master/Crashlytics). | ||
- [feature] Added support for Catalyst (note that Crashlytics still supports tvOS and macOS). | ||
- [feature] Added new APIs that are more consistent with other Firebase SDKs and more intuitive to use. The new APIs also give your users more control over how you collect their data. | ||
- [removed] Removed the Fabric API Key. Now, Crashlytics uses the GoogleService-Info.plist file to associate your app with your project. If you linked your app from Fabric and want to upgrade to the new SDK, remove the Fabric API key from your `run` and `upload-symbols` scripts. We also recommend removing the Fabric section from your app's Info.plist (when you upgrade, Crashlytics uses the new configuration you set up in Firebase). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// 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> | ||
#if CLS_TARGET_OS_HAS_UIKIT | ||
#import <UIKit/UIKit.h> | ||
#endif | ||
|
||
__BEGIN_DECLS | ||
|
||
#define FIRCLSApplicationActivityDefault \ | ||
(NSActivitySuddenTerminationDisabled | NSActivityAutomaticTerminationDisabled) | ||
|
||
/** | ||
* Type to indicate application installation source | ||
*/ | ||
typedef NS_ENUM(NSInteger, FIRCLSApplicationInstallationSourceType) { | ||
FIRCLSApplicationInstallationSourceTypeDeveloperInstall = 1, | ||
// 2 and 3 are reserved for legacy values. | ||
FIRCLSApplicationInstallationSourceTypeAppStore = 4 | ||
}; | ||
|
||
/** | ||
* Returns the application bundle identifier with occurences of "/" replaced by "_" | ||
*/ | ||
NSString* FIRCLSApplicationGetBundleIdentifier(void); | ||
|
||
/** | ||
* Returns the SDK's bundle ID | ||
*/ | ||
NSString* FIRCLSApplicationGetSDKBundleID(void); | ||
|
||
/** | ||
* Returns the platform identifier, either: ios, mac, or tvos. | ||
* Catalyst apps are treated as mac. | ||
*/ | ||
NSString* FIRCLSApplicationGetPlatform(void); | ||
|
||
/** | ||
* Returns the user-facing app name | ||
*/ | ||
NSString* FIRCLSApplicationGetName(void); | ||
|
||
/** | ||
* Returns the build number | ||
*/ | ||
NSString* FIRCLSApplicationGetBundleVersion(void); | ||
|
||
/** | ||
* Returns the human-readable build version | ||
*/ | ||
NSString* FIRCLSApplicationGetShortBundleVersion(void); | ||
|
||
/** | ||
* Returns a number to indicate how the app has been installed: Developer / App Store | ||
*/ | ||
FIRCLSApplicationInstallationSourceType FIRCLSApplicationInstallationSource(void); | ||
|
||
BOOL FIRCLSApplicationIsExtension(void); | ||
NSString* FIRCLSApplicationExtensionPointIdentifier(void); | ||
|
||
#if CLS_TARGET_OS_HAS_UIKIT | ||
UIApplication* FIRCLSApplicationSharedInstance(void); | ||
#else | ||
id FIRCLSApplicationSharedInstance(void); | ||
#endif | ||
|
||
void FIRCLSApplicationOpenURL(NSURL* url, | ||
NSExtensionContext* extensionContext, | ||
void (^completionBlock)(BOOL success)); | ||
|
||
id<NSObject> FIRCLSApplicationBeginActivity(NSActivityOptions options, NSString* reason); | ||
void FIRCLSApplicationEndActivity(id<NSObject> activity); | ||
|
||
void FIRCLSApplicationActivity(NSActivityOptions options, NSString* reason, void (^block)(void)); | ||
|
||
__END_DECLS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
// 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 "FIRCLSApplication.h" | ||
|
||
#import "FIRCLSHost.h" | ||
#import "FIRCLSUtility.h" | ||
|
||
#if CLS_TARGET_OS_OSX | ||
#import <AppKit/AppKit.h> | ||
#endif | ||
|
||
#if CLS_TARGET_OS_HAS_UIKIT | ||
#import <UIKit/UIKit.h> | ||
#endif | ||
|
||
NSString* FIRCLSApplicationGetBundleIdentifier(void) { | ||
return [[[NSBundle mainBundle] bundleIdentifier] stringByReplacingOccurrencesOfString:@"/" | ||
withString:@"_"]; | ||
} | ||
|
||
NSString* FIRCLSApplicationGetSDKBundleID(void) { | ||
return | ||
[@"com.google.firebase.crashlytics." stringByAppendingString:FIRCLSApplicationGetPlatform()]; | ||
} | ||
|
||
NSString* FIRCLSApplicationGetPlatform(void) { | ||
#if defined(TARGET_OS_MACCATALYST) && TARGET_OS_MACCATALYST | ||
return @"mac"; | ||
#elif TARGET_OS_IOS | ||
return @"ios"; | ||
#elif TARGET_OS_OSX | ||
return @"mac"; | ||
#elif TARGET_OS_TV | ||
return @"tvos"; | ||
#endif | ||
} | ||
|
||
// these defaults match the FIRCLSInfoPlist helper in FIRCLSIDEFoundation | ||
NSString* FIRCLSApplicationGetBundleVersion(void) { | ||
return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; | ||
} | ||
|
||
NSString* FIRCLSApplicationGetShortBundleVersion(void) { | ||
return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; | ||
} | ||
|
||
NSString* FIRCLSApplicationGetName(void) { | ||
NSString* name; | ||
NSBundle* mainBundle; | ||
|
||
mainBundle = [NSBundle mainBundle]; | ||
|
||
name = [mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; | ||
if (name) { | ||
return name; | ||
} | ||
|
||
name = [mainBundle objectForInfoDictionaryKey:@"CFBundleName"]; | ||
if (name) { | ||
return name; | ||
} | ||
|
||
return FIRCLSApplicationGetBundleVersion(); | ||
} | ||
|
||
BOOL FIRCLSApplicationHasAppStoreReceipt(void) { | ||
NSURL* url = NSBundle.mainBundle.appStoreReceiptURL; | ||
return [NSFileManager.defaultManager fileExistsAtPath:[url path]]; | ||
} | ||
|
||
FIRCLSApplicationInstallationSourceType FIRCLSApplicationInstallationSource(void) { | ||
if (FIRCLSApplicationHasAppStoreReceipt()) { | ||
return FIRCLSApplicationInstallationSourceTypeAppStore; | ||
} | ||
|
||
return FIRCLSApplicationInstallationSourceTypeDeveloperInstall; | ||
} | ||
|
||
BOOL FIRCLSApplicationIsExtension(void) { | ||
return FIRCLSApplicationExtensionPointIdentifier() != nil; | ||
} | ||
|
||
NSString* FIRCLSApplicationExtensionPointIdentifier(void) { | ||
id extensionDict = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSExtension"]; | ||
|
||
if (!extensionDict) { | ||
return nil; | ||
} | ||
|
||
if (![extensionDict isKindOfClass:[NSDictionary class]]) { | ||
FIRCLSSDKLog("Error: NSExtension Info.plist entry is mal-formed\n"); | ||
return nil; | ||
} | ||
|
||
id typeValue = [(NSDictionary*)extensionDict objectForKey:@"NSExtensionPointIdentifier"]; | ||
|
||
if (![typeValue isKindOfClass:[NSString class]]) { | ||
FIRCLSSDKLog("Error: NSExtensionPointIdentifier Info.plist entry is mal-formed\n"); | ||
return nil; | ||
} | ||
|
||
return typeValue; | ||
} | ||
|
||
#if CLS_TARGET_OS_HAS_UIKIT | ||
UIApplication* FIRCLSApplicationSharedInstance(void) { | ||
if (FIRCLSApplicationIsExtension()) { | ||
return nil; | ||
} | ||
|
||
return [[UIApplication class] performSelector:@selector(sharedApplication)]; | ||
} | ||
#elif CLS_TARGET_OS_OSX | ||
id FIRCLSApplicationSharedInstance(void) { | ||
return [NSClassFromString(@"NSApplication") sharedApplication]; | ||
} | ||
#else | ||
id FIRCLSApplicationSharedInstance(void) { | ||
return nil; // FIXME: what do we actually return for watch? | ||
} | ||
#endif | ||
|
||
void FIRCLSApplicationOpenURL(NSURL* url, | ||
NSExtensionContext* extensionContext, | ||
void (^completionBlock)(BOOL success)) { | ||
if (extensionContext) { | ||
[extensionContext openURL:url completionHandler:completionBlock]; | ||
return; | ||
} | ||
|
||
BOOL result = NO; | ||
|
||
#if TARGET_OS_IOS | ||
// What's going on here is the value returned is a scalar, but we really need an object to | ||
// call this dynamically. Hoops must be jumped. | ||
NSInvocationOperation* op = | ||
[[NSInvocationOperation alloc] initWithTarget:FIRCLSApplicationSharedInstance() | ||
selector:@selector(openURL:) | ||
object:url]; | ||
[op start]; | ||
[op.result getValue:&result]; | ||
#elif CLS_TARGET_OS_OSX | ||
result = [[NSClassFromString(@"NSWorkspace") sharedWorkspace] openURL:url]; | ||
#endif | ||
|
||
completionBlock(result); | ||
} | ||
|
||
id<NSObject> FIRCLSApplicationBeginActivity(NSActivityOptions options, NSString* reason) { | ||
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(beginActivityWithOptions: | ||
reason:)]) { | ||
return [[NSProcessInfo processInfo] beginActivityWithOptions:options reason:reason]; | ||
} | ||
|
||
#if CLS_TARGET_OS_OSX | ||
if (options & NSActivitySuddenTerminationDisabled) { | ||
[[NSProcessInfo processInfo] disableSuddenTermination]; | ||
} | ||
|
||
if (options & NSActivityAutomaticTerminationDisabled) { | ||
[[NSProcessInfo processInfo] disableAutomaticTermination:reason]; | ||
} | ||
#endif | ||
|
||
// encode the options, so we can undo our work later | ||
return @{@"options" : @(options), @"reason" : reason}; | ||
} | ||
|
||
void FIRCLSApplicationEndActivity(id<NSObject> activity) { | ||
if (!activity) { | ||
return; | ||
} | ||
|
||
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(endActivity:)]) { | ||
[[NSProcessInfo processInfo] endActivity:activity]; | ||
return; | ||
} | ||
|
||
#if CLS_TARGET_OS_OSX | ||
NSInteger options = [[(NSDictionary*)activity objectForKey:@"options"] integerValue]; | ||
|
||
if (options & NSActivitySuddenTerminationDisabled) { | ||
[[NSProcessInfo processInfo] enableSuddenTermination]; | ||
} | ||
|
||
if (options & NSActivityAutomaticTerminationDisabled) { | ||
[[NSProcessInfo processInfo] | ||
enableAutomaticTermination:[(NSDictionary*)activity objectForKey:@"reason"]]; | ||
} | ||
#endif | ||
} | ||
|
||
void FIRCLSApplicationActivity(NSActivityOptions options, NSString* reason, void (^block)(void)) { | ||
id<NSObject> activity = FIRCLSApplicationBeginActivity(options, reason); | ||
|
||
block(); | ||
|
||
FIRCLSApplicationEndActivity(activity); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// 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. | ||
|
||
#pragma once | ||
|
||
#include "FIRCLSFeatures.h" | ||
#include "FIRCLSFile.h" | ||
#include "FIRCLSMachO.h" | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
__BEGIN_DECLS | ||
|
||
// Typically, apps seem to have ~300 binary images loaded | ||
#define CLS_BINARY_IMAGE_RUNTIME_NODE_COUNT (512) | ||
#define CLS_BINARY_IMAGE_RUNTIME_NODE_NAME_SIZE (32) | ||
#define CLS_BINARY_IMAGE_RUNTIME_NODE_RECORD_NAME 0 | ||
|
||
#define FIRCLSUUIDStringLength (33) | ||
|
||
typedef struct { | ||
_Atomic(void*) volatile baseAddress; | ||
uint64_t size; | ||
#if CLS_DWARF_UNWINDING_SUPPORTED | ||
const void* ehFrame; | ||
#endif | ||
#if CLS_COMPACT_UNWINDING_SUPPORTED | ||
const void* unwindInfo; | ||
#endif | ||
const void* crashInfo; | ||
#if CLS_BINARY_IMAGE_RUNTIME_NODE_RECORD_NAME | ||
char name[CLS_BINARY_IMAGE_RUNTIME_NODE_NAME_SIZE]; | ||
#endif | ||
} FIRCLSBinaryImageRuntimeNode; | ||
|
||
typedef struct { | ||
char uuidString[FIRCLSUUIDStringLength]; | ||
bool encrypted; | ||
FIRCLSMachOVersion builtSDK; | ||
FIRCLSMachOVersion minSDK; | ||
FIRCLSBinaryImageRuntimeNode node; | ||
struct FIRCLSMachOSlice slice; | ||
intptr_t vmaddr_slide; | ||
} FIRCLSBinaryImageDetails; | ||
|
||
typedef struct { | ||
const char* path; | ||
} FIRCLSBinaryImageReadOnlyContext; | ||
|
||
typedef struct { | ||
FIRCLSFile file; | ||
FIRCLSBinaryImageRuntimeNode nodes[CLS_BINARY_IMAGE_RUNTIME_NODE_COUNT]; | ||
} FIRCLSBinaryImageReadWriteContext; | ||
|
||
void FIRCLSBinaryImageInit(FIRCLSBinaryImageReadOnlyContext* roContext, | ||
FIRCLSBinaryImageReadWriteContext* rwContext); | ||
|
||
#if CLS_COMPACT_UNWINDING_SUPPORTED | ||
bool FIRCLSBinaryImageSafeFindImageForAddress(uintptr_t address, | ||
FIRCLSBinaryImageRuntimeNode* image); | ||
bool FIRCLSBinaryImageSafeHasUnwindInfo(FIRCLSBinaryImageRuntimeNode* image); | ||
#endif | ||
|
||
bool FIRCLSBinaryImageFindImageForUUID(const char* uuidString, | ||
FIRCLSBinaryImageDetails* imageDetails); | ||
|
||
bool FIRCLSBinaryImageRecordMainExecutable(FIRCLSFile* file); | ||
|
||
__END_DECLS |
Oops, something went wrong.