Skip to content

Commit

Permalink
Introducing AardvarkCrashReport
Browse files Browse the repository at this point in the history
  • Loading branch information
NickEntin committed Mar 5, 2021
0 parents commit d3cb4b5
Show file tree
Hide file tree
Showing 22 changed files with 1,689 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# OS X
.DS_Store

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.ipa

# Bundler
.bundle

# Carthage
Carthage/Build

# CocoaPods
Pods/

# Swift Playgrounds
timeline.xctimeline

# Swift Pacakge Manager
generated/
.build/
.swiftpm/
18 changes: 18 additions & 0 deletions AardvarkCrashReport.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Pod::Spec.new do |s|
s.name = 'AardvarkCrashReport'
s.version = '1.0.0'
s.summary = 'AardvarkCrashReport makes it easy to provide high quality data about crashes in your bug reports.'
s.homepage = 'https://github.com/cashapp/AardvarkCrashReport'
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
s.author = 'Square'
s.source = { :git => 'https://github.com/cashapp/AardvarkCrashReport.git', :tag => s.version.to_s }

s.ios.deployment_target = '12.0'

s.static_framework = true

s.source_files = 'Sources/AardvarkCrashReport/**/*.{h,m,swift}'

s.dependency 'Aardvark', '~> 4.0'
s.dependency 'PLCrashReporter', '~> 1.8'
end
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### Sign the CLA

All contributors to your PR must sign our [Individual Contributor License Agreement (CLA)](https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1). The CLA is a short form that ensures that you are eligible to contribute.

### One Issue per Pull Request

Keep your Pull Requests small. Small PRs are easier to reason about which makes them significantly more likely to get merged.

### Issues Before Features

If you want to add a feature, please file an [Issue](https://github.com/CashApp/AardvarkCrashReport/issues) first. An Issue gives us the opportunity to discuss the requirements and implications of a feature with you before you start writing code.

### Backwards Compatibility

Respect the minimum deployment target. If you are adding code that uses new APIs, make sure to prevent older clients from crashing or misbehaving. Our CI runs against our minimum deployment targets, so you will not get a green build unless your code is backwards compatible.

### Forwards Compatibility

Please do not write new code using deprecated APIs.

### Keep the Demo App and Documentation Updated

When adding new features or making changes to existing features, make sure to update the included demo app and documentation so new users can understand what's available.
429 changes: 429 additions & 0 deletions Example/AardvarkCrashReport.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "AardvarkCrashReportDemo.app"
BlueprintName = "AardvarkCrashReportDemo"
ReferencedContainer = "container:AardvarkCrashReport.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "AardvarkCrashReportDemo.app"
BlueprintName = "AardvarkCrashReportDemo"
ReferencedContainer = "container:AardvarkCrashReport.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "AardvarkCrashReportDemo.app"
BlueprintName = "AardvarkCrashReportDemo"
ReferencedContainer = "container:AardvarkCrashReport.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "AardvarkCrashReportDemo.app"
BlueprintName = "AardvarkCrashReportDemo"
ReferencedContainer = "container:AardvarkCrashReport.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
10 changes: 10 additions & 0 deletions Example/AardvarkCrashReport.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
113 changes: 113 additions & 0 deletions Example/AardvarkCrashReport/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//
// Copyright 2021 Square, Inc.
//
// 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:https://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 AardvarkCrashReport
import AardvarkMailUI
import CrashReporter
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

// MARK: - Private Properties

private let crashReporter = PLCrashReporter(configuration: .defaultConfiguration())

private let crashBugReporter = ARKEmailBugReporter(
emailAddress: "[email protected]",
logStore: ARKLogDistributor.default().defaultLogStore
)

private var liveBugReporterAttachmentDelegate: LiveBugReporterAttachmentDelegate?

// MARK: - AppDelegate

var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UINavigationController(rootViewController: ViewController())
window?.makeKeyAndVisible()

// Install the live bug reporter using the default gesture recognizer.
let liveBugReporter = Aardvark.addDefaultBugReportingGestureWithEmailBugReporter(
withRecipient: "[email protected]"
)

if let crashReporter = crashReporter {
do {
try crashReporter.enableAndReturnError()
log("Enabled crash reporter")

} catch {
log(
"Failed to enable crash reporter",
parameters: [
"error": error.localizedDescription,
]
)
}

if crashReporter.hasPendingCrashReport() {
log("Found pending crash report")
} else {
log("No pending crash report found")
}

// Set up an attachment delegate to provide the live crash report attachment.
let liveBugReporterAttachmentDelegate = LiveBugReporterAttachmentDelegate(crashReporter: crashReporter)
self.liveBugReporterAttachmentDelegate = liveBugReporterAttachmentDelegate
liveBugReporter.emailAttachmentAdditionsDelegate = liveBugReporterAttachmentDelegate

} else {
log("Failed to initialize crash reporter")
}

// Wait 1 second so the UI has time to appear, then check for a pending crash report.
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(1)) { [weak self] in
self?.promptForBugReportIfReporterHasPendingCrashReport()
}

return true
}

private func promptForBugReportIfReporterHasPendingCrashReport() {
guard let crashReporter = crashReporter else {
return
}

if let attachment = CrashReportAttachmentGenerator.attachmentForPendingCrashReport(from: crashReporter) {
log("Generated attachment for pending crash report")

guard let presentingViewController = window?.rootViewController else {
log("Failed to present bug reporting prompt")
return
}

let promptingDelegate = CrashBugReporterPromptingDelegate(
attachment: attachment,
presentingViewController: presentingViewController
)
crashBugReporter.promptingDelegate = promptingDelegate

crashBugReporter.composeBugReportWithoutScreenshot()
}
}

}
46 changes: 46 additions & 0 deletions Example/AardvarkCrashReport/Base.lproj/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 CocoaPods. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AardvarkCrashReport" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
</view>
</objects>
</document>
Loading

0 comments on commit d3cb4b5

Please sign in to comment.