├── .gitignore ├── .gitmodules ├── .swiftpm └── xcode │ └── package.xcworkspace │ └── contents.xcworkspacedata ├── .travis.yml ├── CrashReporter.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ ├── CrashReporter.xcscheme │ └── Example.xcscheme ├── CrashReporterMac.podspec ├── Example ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── scheme.imageset │ │ ├── Contents.json │ │ └── scheme.png ├── Base.lproj │ └── MainMenu.xib ├── Example.entitlements └── Info.plist ├── LICENSE ├── Package.swift ├── README.md ├── Sources └── CrashReporter │ ├── CrashLog.swift │ ├── CrashReporter+DefaultsKeys.swift │ ├── CrashReporter.h │ ├── CrashReporter.swift │ ├── CrashReporterBundle.swift │ ├── EmailAddressSetting.swift │ ├── Info.plist │ ├── Infrastructure │ ├── Bundle+InfoKeys.swift │ ├── HTTPURLResponse+valueForHTTPHeaderField.swift │ ├── OneShotDownload.swift │ ├── String+md5.swift │ └── URLResponse+statusIsOK.swift │ ├── SendReportsAutomaticallySetting.swift │ └── UI │ ├── CrashReportWindowController.swift │ └── CrashReporterWindow.xib ├── Tests └── CrashReporterTests │ ├── EmailAddressSettingTests.swift │ ├── Info.plist │ └── SendReportsAutomaticallySettingTests.swift ├── assets ├── reporter-dark.png └── reporter-light.png └── php └── index.php /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "php/vendor/PHPMailer"] 2 | path = php/vendor/PHPMailer 3 | url = https://github.com/PHPMailer/PHPMailer.git 4 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: swift 2 | 3 | branches: 4 | except: 5 | - gh-pages 6 | 7 | install: 8 | - gem install cocoapods --pre -N 9 | - gem install xcpretty -N 10 | 11 | env: 12 | global: 13 | - LC_CTYPE=en_US.UTF-8 14 | - LANG=en_US.UTF-8 15 | - FRAMEWORK_NAME="CrashReporter" 16 | 17 | matrix: 18 | include: 19 | - osx_image: xcode10.2 20 | env: SCHEME="macOS" SDK="macosx10.14" DESTINATION="arch=x86_64" SWIFT_VERSION="5.0" ACTION="test" 21 | 22 | script: 23 | - set -o pipefail 24 | - pod --version 25 | - xcodebuild -version 26 | - xcodebuild -showsdks 27 | - xcodebuild 28 | "$ACTION" 29 | -project "$FRAMEWORK_NAME.xcodeproj" 30 | -scheme "$FRAMEWORK_NAME" 31 | -sdk "$SDK" 32 | -destination "$DESTINATION" 33 | -configuration Debug 34 | ONLY_ACTIVE_ARCH=YES 35 | GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES 36 | GCC_GENERATE_TEST_COVERAGE_FILES=YES 37 | SWIFT_VERSION=$SWIFT_VERSION 38 | - pod lib lint --quick 39 | 40 | after_success: 41 | - bash <(curl -s https://codecov.io/bash) 42 | -------------------------------------------------------------------------------- /CrashReporter.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5004D23C2426216C00BD5875 /* EmailAddressSettingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5004D23B2426216C00BD5875 /* EmailAddressSettingTests.swift */; }; 11 | 501E2A65295481500040C497 /* NoClippingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501E2A64295481500040C497 /* NoClippingView.swift */; }; 12 | 507A3F7B2425F861006A50B6 /* EmailAddressSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507A3F7A2425F861006A50B6 /* EmailAddressSetting.swift */; }; 13 | 50F832DD22C9FBD300DBD0DD /* CrashReporter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F832D322C9FBD300DBD0DD /* CrashReporter.framework */; }; 14 | 50F832E422C9FBD300DBD0DD /* CrashReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F832D622C9FBD300DBD0DD /* CrashReporter.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15 | 50F832FE22CA006600DBD0DD /* String+md5.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F832F222CA006600DBD0DD /* String+md5.swift */; }; 16 | 50F832FF22CA006600DBD0DD /* URLResponse+statusIsOK.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F832F322CA006600DBD0DD /* URLResponse+statusIsOK.swift */; }; 17 | 50F8330022CA006600DBD0DD /* OneShotDownload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F832F422CA006600DBD0DD /* OneShotDownload.swift */; }; 18 | 50F8330122CA006600DBD0DD /* CrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F832F522CA006600DBD0DD /* CrashReporter.swift */; }; 19 | 50F8330222CA006600DBD0DD /* CrashReportWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F832F722CA006600DBD0DD /* CrashReportWindowController.swift */; }; 20 | 50F8330322CA006600DBD0DD /* CrashReporterWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50F832F822CA006600DBD0DD /* CrashReporterWindow.xib */; }; 21 | 50F8330722CA00F600DBD0DD /* CrashLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8330622CA00F600DBD0DD /* CrashLog.swift */; }; 22 | 50F8330922CA027B00DBD0DD /* Bundle+InfoKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8330822CA027B00DBD0DD /* Bundle+InfoKeys.swift */; }; 23 | 50F8330B22CA35B800DBD0DD /* HTTPURLResponse+valueForHTTPHeaderField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8330A22CA35B800DBD0DD /* HTTPURLResponse+valueForHTTPHeaderField.swift */; }; 24 | 50F8331322CA3A3F00DBD0DD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8331222CA3A3F00DBD0DD /* AppDelegate.swift */; }; 25 | 50F8331522CA3A4100DBD0DD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50F8331422CA3A4100DBD0DD /* Assets.xcassets */; }; 26 | 50F8331822CA3A4100DBD0DD /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50F8331622CA3A4100DBD0DD /* MainMenu.xib */; }; 27 | 50F8332222CA823C00DBD0DD /* SendReportsAutomaticallySetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8332122CA823C00DBD0DD /* SendReportsAutomaticallySetting.swift */; }; 28 | 50F8332422CA828700DBD0DD /* CrashReporter+DefaultsKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8332322CA828700DBD0DD /* CrashReporter+DefaultsKeys.swift */; }; 29 | 50F8332722CA9B4B00DBD0DD /* SendReportsAutomaticallySettingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8332622CA9B4B00DBD0DD /* SendReportsAutomaticallySettingTests.swift */; }; 30 | /* End PBXBuildFile section */ 31 | 32 | /* Begin PBXContainerItemProxy section */ 33 | 50F832DE22C9FBD300DBD0DD /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 50F832CA22C9FBD300DBD0DD /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 50F832D222C9FBD300DBD0DD; 38 | remoteInfo = CrashReporter; 39 | }; 40 | 50F8331E22CA46C600DBD0DD /* PBXContainerItemProxy */ = { 41 | isa = PBXContainerItemProxy; 42 | containerPortal = 50F832CA22C9FBD300DBD0DD /* Project object */; 43 | proxyType = 1; 44 | remoteGlobalIDString = 50F832D222C9FBD300DBD0DD; 45 | remoteInfo = CrashReporter; 46 | }; 47 | /* End PBXContainerItemProxy section */ 48 | 49 | /* Begin PBXFileReference section */ 50 | 5004D23B2426216C00BD5875 /* EmailAddressSettingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailAddressSettingTests.swift; sourceTree = ""; }; 51 | 501E2A64295481500040C497 /* NoClippingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoClippingView.swift; sourceTree = ""; }; 52 | 507A3F7A2425F861006A50B6 /* EmailAddressSetting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailAddressSetting.swift; sourceTree = ""; }; 53 | 50D1A8AE22CCC7FB007DC81A /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 54 | 50F832D322C9FBD300DBD0DD /* CrashReporter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CrashReporter.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 50F832D622C9FBD300DBD0DD /* CrashReporter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CrashReporter.h; sourceTree = ""; }; 56 | 50F832D722C9FBD300DBD0DD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | 50F832DC22C9FBD300DBD0DD /* CrashReporterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CrashReporterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 50F832E322C9FBD300DBD0DD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 50F832ED22C9FFBB00DBD0DD /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 60 | 50F832F222CA006600DBD0DD /* String+md5.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+md5.swift"; sourceTree = ""; }; 61 | 50F832F322CA006600DBD0DD /* URLResponse+statusIsOK.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URLResponse+statusIsOK.swift"; sourceTree = ""; }; 62 | 50F832F422CA006600DBD0DD /* OneShotDownload.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OneShotDownload.swift; sourceTree = ""; }; 63 | 50F832F522CA006600DBD0DD /* CrashReporter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrashReporter.swift; sourceTree = ""; }; 64 | 50F832F722CA006600DBD0DD /* CrashReportWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrashReportWindowController.swift; sourceTree = ""; }; 65 | 50F832F822CA006600DBD0DD /* CrashReporterWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CrashReporterWindow.xib; sourceTree = ""; }; 66 | 50F8330622CA00F600DBD0DD /* CrashLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashLog.swift; sourceTree = ""; }; 67 | 50F8330822CA027B00DBD0DD /* Bundle+InfoKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+InfoKeys.swift"; sourceTree = ""; }; 68 | 50F8330A22CA35B800DBD0DD /* HTTPURLResponse+valueForHTTPHeaderField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HTTPURLResponse+valueForHTTPHeaderField.swift"; sourceTree = ""; }; 69 | 50F8331022CA3A3F00DBD0DD /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 70 | 50F8331222CA3A3F00DBD0DD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 71 | 50F8331422CA3A4100DBD0DD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 72 | 50F8331722CA3A4100DBD0DD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 73 | 50F8331922CA3A4100DBD0DD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 74 | 50F8331A22CA3A4100DBD0DD /* Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Example.entitlements; sourceTree = ""; }; 75 | 50F8332122CA823C00DBD0DD /* SendReportsAutomaticallySetting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendReportsAutomaticallySetting.swift; sourceTree = ""; }; 76 | 50F8332322CA828700DBD0DD /* CrashReporter+DefaultsKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CrashReporter+DefaultsKeys.swift"; sourceTree = ""; }; 77 | 50F8332622CA9B4B00DBD0DD /* SendReportsAutomaticallySettingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendReportsAutomaticallySettingTests.swift; sourceTree = ""; }; 78 | /* End PBXFileReference section */ 79 | 80 | /* Begin PBXFrameworksBuildPhase section */ 81 | 50F832D022C9FBD300DBD0DD /* Frameworks */ = { 82 | isa = PBXFrameworksBuildPhase; 83 | buildActionMask = 2147483647; 84 | files = ( 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | 50F832D922C9FBD300DBD0DD /* Frameworks */ = { 89 | isa = PBXFrameworksBuildPhase; 90 | buildActionMask = 2147483647; 91 | files = ( 92 | 50F832DD22C9FBD300DBD0DD /* CrashReporter.framework in Frameworks */, 93 | ); 94 | runOnlyForDeploymentPostprocessing = 0; 95 | }; 96 | 50F8330D22CA3A3F00DBD0DD /* Frameworks */ = { 97 | isa = PBXFrameworksBuildPhase; 98 | buildActionMask = 2147483647; 99 | files = ( 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | /* End PBXFrameworksBuildPhase section */ 104 | 105 | /* Begin PBXGroup section */ 106 | 50F832C922C9FBD300DBD0DD = { 107 | isa = PBXGroup; 108 | children = ( 109 | 50D1A8AE22CCC7FB007DC81A /* README.md */, 110 | 50F832ED22C9FFBB00DBD0DD /* LICENSE */, 111 | 50F832D522C9FBD300DBD0DD /* CrashReporter */, 112 | 50F832E022C9FBD300DBD0DD /* CrashReporterTests */, 113 | 50F8331122CA3A3F00DBD0DD /* Example */, 114 | 50F832D422C9FBD300DBD0DD /* Products */, 115 | ); 116 | sourceTree = ""; 117 | }; 118 | 50F832D422C9FBD300DBD0DD /* Products */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 50F832D322C9FBD300DBD0DD /* CrashReporter.framework */, 122 | 50F832DC22C9FBD300DBD0DD /* CrashReporterTests.xctest */, 123 | 50F8331022CA3A3F00DBD0DD /* Example.app */, 124 | ); 125 | name = Products; 126 | sourceTree = ""; 127 | }; 128 | 50F832D522C9FBD300DBD0DD /* CrashReporter */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 50F832D622C9FBD300DBD0DD /* CrashReporter.h */, 132 | 50F832F522CA006600DBD0DD /* CrashReporter.swift */, 133 | 50F8332322CA828700DBD0DD /* CrashReporter+DefaultsKeys.swift */, 134 | 50F8330622CA00F600DBD0DD /* CrashLog.swift */, 135 | 507A3F7A2425F861006A50B6 /* EmailAddressSetting.swift */, 136 | 50F8332122CA823C00DBD0DD /* SendReportsAutomaticallySetting.swift */, 137 | 50F832F622CA006600DBD0DD /* UI */, 138 | 50F832F122CA006600DBD0DD /* Infrastructure */, 139 | 50F832D722C9FBD300DBD0DD /* Info.plist */, 140 | ); 141 | name = CrashReporter; 142 | path = Sources/CrashReporter; 143 | sourceTree = ""; 144 | }; 145 | 50F832E022C9FBD300DBD0DD /* CrashReporterTests */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 50F832E322C9FBD300DBD0DD /* Info.plist */, 149 | 50F8332622CA9B4B00DBD0DD /* SendReportsAutomaticallySettingTests.swift */, 150 | 5004D23B2426216C00BD5875 /* EmailAddressSettingTests.swift */, 151 | ); 152 | name = CrashReporterTests; 153 | path = Tests/CrashReporterTests; 154 | sourceTree = ""; 155 | }; 156 | 50F832F122CA006600DBD0DD /* Infrastructure */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | 50F8330822CA027B00DBD0DD /* Bundle+InfoKeys.swift */, 160 | 50F8330A22CA35B800DBD0DD /* HTTPURLResponse+valueForHTTPHeaderField.swift */, 161 | 50F832F422CA006600DBD0DD /* OneShotDownload.swift */, 162 | 50F832F222CA006600DBD0DD /* String+md5.swift */, 163 | 50F832F322CA006600DBD0DD /* URLResponse+statusIsOK.swift */, 164 | ); 165 | path = Infrastructure; 166 | sourceTree = ""; 167 | }; 168 | 50F832F622CA006600DBD0DD /* UI */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | 50F832F722CA006600DBD0DD /* CrashReportWindowController.swift */, 172 | 501E2A64295481500040C497 /* NoClippingView.swift */, 173 | 50F832F822CA006600DBD0DD /* CrashReporterWindow.xib */, 174 | ); 175 | path = UI; 176 | sourceTree = ""; 177 | }; 178 | 50F8331122CA3A3F00DBD0DD /* Example */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | 50F8331222CA3A3F00DBD0DD /* AppDelegate.swift */, 182 | 50F8331422CA3A4100DBD0DD /* Assets.xcassets */, 183 | 50F8331622CA3A4100DBD0DD /* MainMenu.xib */, 184 | 50F8331922CA3A4100DBD0DD /* Info.plist */, 185 | 50F8331A22CA3A4100DBD0DD /* Example.entitlements */, 186 | ); 187 | path = Example; 188 | sourceTree = ""; 189 | }; 190 | /* End PBXGroup section */ 191 | 192 | /* Begin PBXHeadersBuildPhase section */ 193 | 50F832CE22C9FBD300DBD0DD /* Headers */ = { 194 | isa = PBXHeadersBuildPhase; 195 | buildActionMask = 2147483647; 196 | files = ( 197 | 50F832E422C9FBD300DBD0DD /* CrashReporter.h in Headers */, 198 | ); 199 | runOnlyForDeploymentPostprocessing = 0; 200 | }; 201 | /* End PBXHeadersBuildPhase section */ 202 | 203 | /* Begin PBXNativeTarget section */ 204 | 50F832D222C9FBD300DBD0DD /* CrashReporter */ = { 205 | isa = PBXNativeTarget; 206 | buildConfigurationList = 50F832E722C9FBD300DBD0DD /* Build configuration list for PBXNativeTarget "CrashReporter" */; 207 | buildPhases = ( 208 | 50F832CE22C9FBD300DBD0DD /* Headers */, 209 | 50F832CF22C9FBD300DBD0DD /* Sources */, 210 | 50F832D022C9FBD300DBD0DD /* Frameworks */, 211 | 50F832D122C9FBD300DBD0DD /* Resources */, 212 | ); 213 | buildRules = ( 214 | ); 215 | dependencies = ( 216 | ); 217 | name = CrashReporter; 218 | productName = CrashReporter; 219 | productReference = 50F832D322C9FBD300DBD0DD /* CrashReporter.framework */; 220 | productType = "com.apple.product-type.framework"; 221 | }; 222 | 50F832DB22C9FBD300DBD0DD /* CrashReporterTests */ = { 223 | isa = PBXNativeTarget; 224 | buildConfigurationList = 50F832EA22C9FBD300DBD0DD /* Build configuration list for PBXNativeTarget "CrashReporterTests" */; 225 | buildPhases = ( 226 | 50F832D822C9FBD300DBD0DD /* Sources */, 227 | 50F832D922C9FBD300DBD0DD /* Frameworks */, 228 | 50F832DA22C9FBD300DBD0DD /* Resources */, 229 | ); 230 | buildRules = ( 231 | ); 232 | dependencies = ( 233 | 50F832DF22C9FBD300DBD0DD /* PBXTargetDependency */, 234 | ); 235 | name = CrashReporterTests; 236 | productName = CrashReporterTests; 237 | productReference = 50F832DC22C9FBD300DBD0DD /* CrashReporterTests.xctest */; 238 | productType = "com.apple.product-type.bundle.unit-test"; 239 | }; 240 | 50F8330F22CA3A3F00DBD0DD /* Example */ = { 241 | isa = PBXNativeTarget; 242 | buildConfigurationList = 50F8331B22CA3A4100DBD0DD /* Build configuration list for PBXNativeTarget "Example" */; 243 | buildPhases = ( 244 | 50F8330C22CA3A3F00DBD0DD /* Sources */, 245 | 50F8330D22CA3A3F00DBD0DD /* Frameworks */, 246 | 50F8330E22CA3A3F00DBD0DD /* Resources */, 247 | ); 248 | buildRules = ( 249 | ); 250 | dependencies = ( 251 | 50F8331F22CA46C600DBD0DD /* PBXTargetDependency */, 252 | ); 253 | name = Example; 254 | productName = Example; 255 | productReference = 50F8331022CA3A3F00DBD0DD /* Example.app */; 256 | productType = "com.apple.product-type.application"; 257 | }; 258 | /* End PBXNativeTarget section */ 259 | 260 | /* Begin PBXProject section */ 261 | 50F832CA22C9FBD300DBD0DD /* Project object */ = { 262 | isa = PBXProject; 263 | attributes = { 264 | LastSwiftUpdateCheck = 1020; 265 | LastUpgradeCheck = 1420; 266 | ORGANIZATIONNAME = "Christian Tietze"; 267 | TargetAttributes = { 268 | 50F832D222C9FBD300DBD0DD = { 269 | CreatedOnToolsVersion = 10.2; 270 | LastSwiftMigration = 1020; 271 | }; 272 | 50F832DB22C9FBD300DBD0DD = { 273 | CreatedOnToolsVersion = 10.2; 274 | LastSwiftMigration = 1020; 275 | }; 276 | 50F8330F22CA3A3F00DBD0DD = { 277 | CreatedOnToolsVersion = 10.2; 278 | SystemCapabilities = { 279 | com.apple.Sandbox = { 280 | enabled = 0; 281 | }; 282 | }; 283 | }; 284 | }; 285 | }; 286 | buildConfigurationList = 50F832CD22C9FBD300DBD0DD /* Build configuration list for PBXProject "CrashReporter" */; 287 | compatibilityVersion = "Xcode 9.3"; 288 | developmentRegion = en; 289 | hasScannedForEncodings = 0; 290 | knownRegions = ( 291 | en, 292 | Base, 293 | ); 294 | mainGroup = 50F832C922C9FBD300DBD0DD; 295 | productRefGroup = 50F832D422C9FBD300DBD0DD /* Products */; 296 | projectDirPath = ""; 297 | projectRoot = ""; 298 | targets = ( 299 | 50F832D222C9FBD300DBD0DD /* CrashReporter */, 300 | 50F832DB22C9FBD300DBD0DD /* CrashReporterTests */, 301 | 50F8330F22CA3A3F00DBD0DD /* Example */, 302 | ); 303 | }; 304 | /* End PBXProject section */ 305 | 306 | /* Begin PBXResourcesBuildPhase section */ 307 | 50F832D122C9FBD300DBD0DD /* Resources */ = { 308 | isa = PBXResourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | 50F8330322CA006600DBD0DD /* CrashReporterWindow.xib in Resources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | 50F832DA22C9FBD300DBD0DD /* Resources */ = { 316 | isa = PBXResourcesBuildPhase; 317 | buildActionMask = 2147483647; 318 | files = ( 319 | ); 320 | runOnlyForDeploymentPostprocessing = 0; 321 | }; 322 | 50F8330E22CA3A3F00DBD0DD /* Resources */ = { 323 | isa = PBXResourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | 50F8331522CA3A4100DBD0DD /* Assets.xcassets in Resources */, 327 | 50F8331822CA3A4100DBD0DD /* MainMenu.xib in Resources */, 328 | ); 329 | runOnlyForDeploymentPostprocessing = 0; 330 | }; 331 | /* End PBXResourcesBuildPhase section */ 332 | 333 | /* Begin PBXSourcesBuildPhase section */ 334 | 50F832CF22C9FBD300DBD0DD /* Sources */ = { 335 | isa = PBXSourcesBuildPhase; 336 | buildActionMask = 2147483647; 337 | files = ( 338 | 50F8330122CA006600DBD0DD /* CrashReporter.swift in Sources */, 339 | 501E2A65295481500040C497 /* NoClippingView.swift in Sources */, 340 | 50F8330922CA027B00DBD0DD /* Bundle+InfoKeys.swift in Sources */, 341 | 50F8330B22CA35B800DBD0DD /* HTTPURLResponse+valueForHTTPHeaderField.swift in Sources */, 342 | 50F8330222CA006600DBD0DD /* CrashReportWindowController.swift in Sources */, 343 | 50F832FF22CA006600DBD0DD /* URLResponse+statusIsOK.swift in Sources */, 344 | 50F8332422CA828700DBD0DD /* CrashReporter+DefaultsKeys.swift in Sources */, 345 | 50F8330022CA006600DBD0DD /* OneShotDownload.swift in Sources */, 346 | 50F8330722CA00F600DBD0DD /* CrashLog.swift in Sources */, 347 | 50F8332222CA823C00DBD0DD /* SendReportsAutomaticallySetting.swift in Sources */, 348 | 50F832FE22CA006600DBD0DD /* String+md5.swift in Sources */, 349 | 507A3F7B2425F861006A50B6 /* EmailAddressSetting.swift in Sources */, 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | }; 353 | 50F832D822C9FBD300DBD0DD /* Sources */ = { 354 | isa = PBXSourcesBuildPhase; 355 | buildActionMask = 2147483647; 356 | files = ( 357 | 5004D23C2426216C00BD5875 /* EmailAddressSettingTests.swift in Sources */, 358 | 50F8332722CA9B4B00DBD0DD /* SendReportsAutomaticallySettingTests.swift in Sources */, 359 | ); 360 | runOnlyForDeploymentPostprocessing = 0; 361 | }; 362 | 50F8330C22CA3A3F00DBD0DD /* Sources */ = { 363 | isa = PBXSourcesBuildPhase; 364 | buildActionMask = 2147483647; 365 | files = ( 366 | 50F8331322CA3A3F00DBD0DD /* AppDelegate.swift in Sources */, 367 | ); 368 | runOnlyForDeploymentPostprocessing = 0; 369 | }; 370 | /* End PBXSourcesBuildPhase section */ 371 | 372 | /* Begin PBXTargetDependency section */ 373 | 50F832DF22C9FBD300DBD0DD /* PBXTargetDependency */ = { 374 | isa = PBXTargetDependency; 375 | target = 50F832D222C9FBD300DBD0DD /* CrashReporter */; 376 | targetProxy = 50F832DE22C9FBD300DBD0DD /* PBXContainerItemProxy */; 377 | }; 378 | 50F8331F22CA46C600DBD0DD /* PBXTargetDependency */ = { 379 | isa = PBXTargetDependency; 380 | target = 50F832D222C9FBD300DBD0DD /* CrashReporter */; 381 | targetProxy = 50F8331E22CA46C600DBD0DD /* PBXContainerItemProxy */; 382 | }; 383 | /* End PBXTargetDependency section */ 384 | 385 | /* Begin PBXVariantGroup section */ 386 | 50F8331622CA3A4100DBD0DD /* MainMenu.xib */ = { 387 | isa = PBXVariantGroup; 388 | children = ( 389 | 50F8331722CA3A4100DBD0DD /* Base */, 390 | ); 391 | name = MainMenu.xib; 392 | sourceTree = ""; 393 | }; 394 | /* End PBXVariantGroup section */ 395 | 396 | /* Begin XCBuildConfiguration section */ 397 | 50F832E522C9FBD300DBD0DD /* Debug */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | ALWAYS_SEARCH_USER_PATHS = NO; 401 | CLANG_ANALYZER_NONNULL = YES; 402 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 403 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 404 | CLANG_CXX_LIBRARY = "libc++"; 405 | CLANG_ENABLE_MODULES = YES; 406 | CLANG_ENABLE_OBJC_ARC = YES; 407 | CLANG_ENABLE_OBJC_WEAK = YES; 408 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 409 | CLANG_WARN_BOOL_CONVERSION = YES; 410 | CLANG_WARN_COMMA = YES; 411 | CLANG_WARN_CONSTANT_CONVERSION = YES; 412 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 413 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 414 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 415 | CLANG_WARN_EMPTY_BODY = YES; 416 | CLANG_WARN_ENUM_CONVERSION = YES; 417 | CLANG_WARN_INFINITE_RECURSION = YES; 418 | CLANG_WARN_INT_CONVERSION = YES; 419 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 420 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 421 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 422 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 423 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 424 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 425 | CLANG_WARN_STRICT_PROTOTYPES = YES; 426 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 427 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 428 | CLANG_WARN_UNREACHABLE_CODE = YES; 429 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 430 | CODE_SIGN_STYLE = Manual; 431 | COPY_PHASE_STRIP = NO; 432 | CURRENT_PROJECT_VERSION = 1; 433 | DEAD_CODE_STRIPPING = YES; 434 | DEBUG_INFORMATION_FORMAT = dwarf; 435 | ENABLE_STRICT_OBJC_MSGSEND = YES; 436 | ENABLE_TESTABILITY = YES; 437 | GCC_C_LANGUAGE_STANDARD = gnu11; 438 | GCC_DYNAMIC_NO_PIC = NO; 439 | GCC_NO_COMMON_BLOCKS = YES; 440 | GCC_OPTIMIZATION_LEVEL = 0; 441 | GCC_PREPROCESSOR_DEFINITIONS = ( 442 | "DEBUG=1", 443 | "$(inherited)", 444 | ); 445 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 446 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 447 | GCC_WARN_UNDECLARED_SELECTOR = YES; 448 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 449 | GCC_WARN_UNUSED_FUNCTION = YES; 450 | GCC_WARN_UNUSED_VARIABLE = YES; 451 | MACOSX_DEPLOYMENT_TARGET = 10.13; 452 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 453 | MTL_FAST_MATH = YES; 454 | ONLY_ACTIVE_ARCH = YES; 455 | SDKROOT = macosx; 456 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 457 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 458 | VERSIONING_SYSTEM = "apple-generic"; 459 | VERSION_INFO_PREFIX = ""; 460 | }; 461 | name = Debug; 462 | }; 463 | 50F832E622C9FBD300DBD0DD /* Release */ = { 464 | isa = XCBuildConfiguration; 465 | buildSettings = { 466 | ALWAYS_SEARCH_USER_PATHS = NO; 467 | CLANG_ANALYZER_NONNULL = YES; 468 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 469 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 470 | CLANG_CXX_LIBRARY = "libc++"; 471 | CLANG_ENABLE_MODULES = YES; 472 | CLANG_ENABLE_OBJC_ARC = YES; 473 | CLANG_ENABLE_OBJC_WEAK = YES; 474 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 475 | CLANG_WARN_BOOL_CONVERSION = YES; 476 | CLANG_WARN_COMMA = YES; 477 | CLANG_WARN_CONSTANT_CONVERSION = YES; 478 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 479 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 480 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 481 | CLANG_WARN_EMPTY_BODY = YES; 482 | CLANG_WARN_ENUM_CONVERSION = YES; 483 | CLANG_WARN_INFINITE_RECURSION = YES; 484 | CLANG_WARN_INT_CONVERSION = YES; 485 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 486 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 487 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 488 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 489 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 490 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 491 | CLANG_WARN_STRICT_PROTOTYPES = YES; 492 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 493 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 494 | CLANG_WARN_UNREACHABLE_CODE = YES; 495 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 496 | CODE_SIGN_STYLE = Manual; 497 | COPY_PHASE_STRIP = NO; 498 | CURRENT_PROJECT_VERSION = 1; 499 | DEAD_CODE_STRIPPING = YES; 500 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 501 | ENABLE_NS_ASSERTIONS = NO; 502 | ENABLE_STRICT_OBJC_MSGSEND = YES; 503 | GCC_C_LANGUAGE_STANDARD = gnu11; 504 | GCC_NO_COMMON_BLOCKS = YES; 505 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 506 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 507 | GCC_WARN_UNDECLARED_SELECTOR = YES; 508 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 509 | GCC_WARN_UNUSED_FUNCTION = YES; 510 | GCC_WARN_UNUSED_VARIABLE = YES; 511 | MACOSX_DEPLOYMENT_TARGET = 10.13; 512 | MTL_ENABLE_DEBUG_INFO = NO; 513 | MTL_FAST_MATH = YES; 514 | SDKROOT = macosx; 515 | SWIFT_COMPILATION_MODE = wholemodule; 516 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 517 | VERSIONING_SYSTEM = "apple-generic"; 518 | VERSION_INFO_PREFIX = ""; 519 | }; 520 | name = Release; 521 | }; 522 | 50F832E822C9FBD300DBD0DD /* Debug */ = { 523 | isa = XCBuildConfiguration; 524 | buildSettings = { 525 | CLANG_ENABLE_MODULES = YES; 526 | COMBINE_HIDPI_IMAGES = YES; 527 | DEAD_CODE_STRIPPING = YES; 528 | DEFINES_MODULE = YES; 529 | DYLIB_COMPATIBILITY_VERSION = 1; 530 | DYLIB_CURRENT_VERSION = 1; 531 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 532 | FRAMEWORK_VERSION = A; 533 | INFOPLIST_FILE = Sources/CrashReporter/Info.plist; 534 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 535 | LD_RUNPATH_SEARCH_PATHS = ( 536 | "$(inherited)", 537 | "@executable_path/../Frameworks", 538 | "@loader_path/Frameworks", 539 | ); 540 | PRODUCT_BUNDLE_IDENTIFIER = de.christiantietze.CrashReporter; 541 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 542 | SKIP_INSTALL = YES; 543 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 544 | SWIFT_VERSION = 5.0; 545 | }; 546 | name = Debug; 547 | }; 548 | 50F832E922C9FBD300DBD0DD /* Release */ = { 549 | isa = XCBuildConfiguration; 550 | buildSettings = { 551 | CLANG_ENABLE_MODULES = YES; 552 | COMBINE_HIDPI_IMAGES = YES; 553 | DEAD_CODE_STRIPPING = YES; 554 | DEFINES_MODULE = YES; 555 | DYLIB_COMPATIBILITY_VERSION = 1; 556 | DYLIB_CURRENT_VERSION = 1; 557 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 558 | FRAMEWORK_VERSION = A; 559 | INFOPLIST_FILE = Sources/CrashReporter/Info.plist; 560 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 561 | LD_RUNPATH_SEARCH_PATHS = ( 562 | "$(inherited)", 563 | "@executable_path/../Frameworks", 564 | "@loader_path/Frameworks", 565 | ); 566 | PRODUCT_BUNDLE_IDENTIFIER = de.christiantietze.CrashReporter; 567 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 568 | SKIP_INSTALL = YES; 569 | SWIFT_VERSION = 5.0; 570 | }; 571 | name = Release; 572 | }; 573 | 50F832EB22C9FBD300DBD0DD /* Debug */ = { 574 | isa = XCBuildConfiguration; 575 | buildSettings = { 576 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 577 | CLANG_ENABLE_MODULES = YES; 578 | COMBINE_HIDPI_IMAGES = YES; 579 | DEAD_CODE_STRIPPING = YES; 580 | INFOPLIST_FILE = Tests/CrashReporterTests/Info.plist; 581 | LD_RUNPATH_SEARCH_PATHS = ( 582 | "$(inherited)", 583 | "@executable_path/../Frameworks", 584 | "@loader_path/../Frameworks", 585 | ); 586 | MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; 587 | PRODUCT_BUNDLE_IDENTIFIER = de.christiantietze.CrashReporterTests; 588 | PRODUCT_NAME = "$(TARGET_NAME)"; 589 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 590 | SWIFT_VERSION = 5.0; 591 | }; 592 | name = Debug; 593 | }; 594 | 50F832EC22C9FBD300DBD0DD /* Release */ = { 595 | isa = XCBuildConfiguration; 596 | buildSettings = { 597 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 598 | CLANG_ENABLE_MODULES = YES; 599 | COMBINE_HIDPI_IMAGES = YES; 600 | DEAD_CODE_STRIPPING = YES; 601 | INFOPLIST_FILE = Tests/CrashReporterTests/Info.plist; 602 | LD_RUNPATH_SEARCH_PATHS = ( 603 | "$(inherited)", 604 | "@executable_path/../Frameworks", 605 | "@loader_path/../Frameworks", 606 | ); 607 | MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; 608 | PRODUCT_BUNDLE_IDENTIFIER = de.christiantietze.CrashReporterTests; 609 | PRODUCT_NAME = "$(TARGET_NAME)"; 610 | SWIFT_VERSION = 5.0; 611 | }; 612 | name = Release; 613 | }; 614 | 50F8331C22CA3A4100DBD0DD /* Debug */ = { 615 | isa = XCBuildConfiguration; 616 | buildSettings = { 617 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 618 | CODE_SIGN_IDENTITY = "-"; 619 | COMBINE_HIDPI_IMAGES = YES; 620 | DEAD_CODE_STRIPPING = YES; 621 | INFOPLIST_FILE = Example/Info.plist; 622 | LD_RUNPATH_SEARCH_PATHS = ( 623 | "$(inherited)", 624 | "@executable_path/../Frameworks", 625 | ); 626 | MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; 627 | PRODUCT_BUNDLE_IDENTIFIER = de.christiantietze.CrashReporter.Example; 628 | PRODUCT_NAME = "$(TARGET_NAME)"; 629 | SWIFT_VERSION = 5.0; 630 | }; 631 | name = Debug; 632 | }; 633 | 50F8331D22CA3A4100DBD0DD /* Release */ = { 634 | isa = XCBuildConfiguration; 635 | buildSettings = { 636 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 637 | CODE_SIGN_IDENTITY = "-"; 638 | COMBINE_HIDPI_IMAGES = YES; 639 | DEAD_CODE_STRIPPING = YES; 640 | INFOPLIST_FILE = Example/Info.plist; 641 | LD_RUNPATH_SEARCH_PATHS = ( 642 | "$(inherited)", 643 | "@executable_path/../Frameworks", 644 | ); 645 | MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; 646 | PRODUCT_BUNDLE_IDENTIFIER = de.christiantietze.CrashReporter.Example; 647 | PRODUCT_NAME = "$(TARGET_NAME)"; 648 | SWIFT_VERSION = 5.0; 649 | }; 650 | name = Release; 651 | }; 652 | /* End XCBuildConfiguration section */ 653 | 654 | /* Begin XCConfigurationList section */ 655 | 50F832CD22C9FBD300DBD0DD /* Build configuration list for PBXProject "CrashReporter" */ = { 656 | isa = XCConfigurationList; 657 | buildConfigurations = ( 658 | 50F832E522C9FBD300DBD0DD /* Debug */, 659 | 50F832E622C9FBD300DBD0DD /* Release */, 660 | ); 661 | defaultConfigurationIsVisible = 0; 662 | defaultConfigurationName = Release; 663 | }; 664 | 50F832E722C9FBD300DBD0DD /* Build configuration list for PBXNativeTarget "CrashReporter" */ = { 665 | isa = XCConfigurationList; 666 | buildConfigurations = ( 667 | 50F832E822C9FBD300DBD0DD /* Debug */, 668 | 50F832E922C9FBD300DBD0DD /* Release */, 669 | ); 670 | defaultConfigurationIsVisible = 0; 671 | defaultConfigurationName = Release; 672 | }; 673 | 50F832EA22C9FBD300DBD0DD /* Build configuration list for PBXNativeTarget "CrashReporterTests" */ = { 674 | isa = XCConfigurationList; 675 | buildConfigurations = ( 676 | 50F832EB22C9FBD300DBD0DD /* Debug */, 677 | 50F832EC22C9FBD300DBD0DD /* Release */, 678 | ); 679 | defaultConfigurationIsVisible = 0; 680 | defaultConfigurationName = Release; 681 | }; 682 | 50F8331B22CA3A4100DBD0DD /* Build configuration list for PBXNativeTarget "Example" */ = { 683 | isa = XCConfigurationList; 684 | buildConfigurations = ( 685 | 50F8331C22CA3A4100DBD0DD /* Debug */, 686 | 50F8331D22CA3A4100DBD0DD /* Release */, 687 | ); 688 | defaultConfigurationIsVisible = 0; 689 | defaultConfigurationName = Release; 690 | }; 691 | /* End XCConfigurationList section */ 692 | }; 693 | rootObject = 50F832CA22C9FBD300DBD0DD /* Project object */; 694 | } 695 | -------------------------------------------------------------------------------- /CrashReporter.xcodeproj/xcshareddata/xcschemes/CrashReporter.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 48 | 49 | 50 | 51 | 52 | 62 | 63 | 69 | 70 | 71 | 72 | 78 | 79 | 85 | 86 | 87 | 88 | 90 | 91 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /CrashReporter.xcodeproj/xcshareddata/xcschemes/Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 48 | 49 | 50 | 51 | 52 | 62 | 64 | 70 | 71 | 72 | 73 | 79 | 81 | 87 | 88 | 89 | 90 | 92 | 93 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /CrashReporterMac.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'CrashReporterMac' 3 | s.version = '0.4.5' 4 | s.summary = 'Collects and sends crash reports for macOS applications.' 5 | 6 | s.description = <<-DESC 7 | macOS framework to prompt users to send crash logs after your app has crashes. 8 | 9 | Supports automatically sending reports if the user choses to. 10 | DESC 11 | 12 | s.homepage = 'https://github.com/CleanCocoa/CrashReporter' 13 | s.screenshots = 'https://raw.githubusercontent.com/CleanCocoa/CrashReporter/master/assets/reporter-light.png', 'https://raw.githubusercontent.com/CleanCocoa/CrashReporter/master/assets/reporter-dark.png' 14 | s.license = { :type => 'MIT', :file => 'LICENSE' } 15 | s.author = { 'Christian Tietze' => 'me@christiantietze.de' } 16 | s.social_media_url = 'https://twitter.com/ctietze' 17 | 18 | s.source = { :git => 'https://github.com/CleanCocoa/CrashReporter.git', :tag => s.version.to_s } 19 | s.platform = :macos, '10.13' 20 | s.swift_version = '5' 21 | s.source_files = 'Sources/**/*.swift' 22 | s.frameworks = 'Cocoa' 23 | end 24 | -------------------------------------------------------------------------------- /Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | import Cocoa 5 | import CrashReporter 6 | 7 | 8 | // 9 | // Please Note 10 | // ----------- 11 | // 12 | // The Example.app scheme is configured to run without a debugger attached. 13 | // This way, the app can crash and produce a crash log. 14 | // 15 | // That meant you cannot use breakpoints inside the app, too. 16 | // 17 | 18 | 19 | /// Assuming you run the server script from `php -S 127.0.0.1:3333`. 20 | let crashReporterURL = URL(string: "http://127.0.0.1:3333/")! 21 | 22 | @NSApplicationMain 23 | class AppDelegate: NSObject, NSApplicationDelegate { 24 | 25 | @IBOutlet weak var window: NSWindow! 26 | 27 | lazy var crashReporter = CrashReporter( 28 | crashReporterURL: crashReporterURL, 29 | privacyPolicyURL: URL(string: "https://example.com/privacy-policy")!) 30 | 31 | func applicationDidFinishLaunching(_ aNotification: Notification) { 32 | crashReporter.check(collectEmailAddress: true, 33 | alwaysShowCrashReporterWindow: false, 34 | displayCrashReporterWindowAsModal: true) 35 | } 36 | 37 | /// Cocoa binding-enabled wrapper for the preference setting. 38 | /// 39 | /// Will not update the crash reporter window checkbox state, because that one 40 | /// doesn't use a `NSUserDefaultsController` which would be notified by the 41 | /// underlying defaults setting. (I think that's overkill for this simple task.) 42 | @objc public dynamic var sendCrashReportsAutomatically: Bool { 43 | get { 44 | return crashReporter.sendCrashReportsAutomatically 45 | } 46 | set { 47 | crashReporter.sendCrashReportsAutomatically = newValue 48 | } 49 | } 50 | 51 | @IBAction func crashApp(_ sender: Any?) { 52 | if isDebuggerAttached { 53 | showDebugWarning() 54 | } else { 55 | fatalError("Intentional crash.") 56 | } 57 | } 58 | 59 | private func showDebugWarning() { 60 | let alert = NSAlert() 61 | alert.accessoryView = { 62 | let imageView = NSImageView(frame: .init(x: 0, y: 0, width: 415, height: 84)) 63 | imageView.image = NSImage(named: "scheme")! // Force-try ok in example app :) 64 | return imageView 65 | }() 66 | alert.messageText = "Cannot create crash log in DEBUG mode" 67 | alert.informativeText = "Change your Example.app scheme in Xcode: run this with the \"Release\" build configuration and disable running as \"Debug Executable\" ." 68 | alert.addButton(withTitle: "Continue") 69 | _ = alert.runModal() 70 | } 71 | } 72 | 73 | let isDebuggerAttached: Bool = { 74 | var debuggerIsAttached = false 75 | 76 | var name: [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()] 77 | var info: kinfo_proc = kinfo_proc() 78 | var info_size = MemoryLayout.size 79 | 80 | let success = name.withUnsafeMutableBytes { (nameBytePtr: UnsafeMutableRawBufferPointer) -> Bool in 81 | guard let nameBytesBlindMemory = nameBytePtr.bindMemory(to: Int32.self).baseAddress else { return false } 82 | return -1 != sysctl(nameBytesBlindMemory, 4, &info, &info_size, nil, 0) 83 | } 84 | 85 | if !success { 86 | debuggerIsAttached = false 87 | } 88 | 89 | if !debuggerIsAttached && (info.kp_proc.p_flag & P_TRACED) != 0 { 90 | debuggerIsAttached = true 91 | } 92 | 93 | return debuggerIsAttached 94 | }() 95 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/scheme.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "scheme.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/scheme.imageset/scheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CleanCocoa/CrashReporter/30e31eac5cad1ec7f34330a3bd3feba14c357aec/Example/Assets.xcassets/scheme.imageset/scheme.png -------------------------------------------------------------------------------- /Example/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | Default 539 | 540 | 541 | 542 | 543 | 544 | 545 | Left to Right 546 | 547 | 548 | 549 | 550 | 551 | 552 | Right to Left 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | Default 564 | 565 | 566 | 567 | 568 | 569 | 570 | Left to Right 571 | 572 | 573 | 574 | 575 | 576 | 577 | Right to Left 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | -------------------------------------------------------------------------------- /Example/Example.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2019 Christian Tietze. All rights reserved. 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2019 Brent Simmons. 4 | Copyright (c) 2018 Ranchero Software. 5 | Copyright (c) 2019 Christian Tietze. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | 3 | // Copyright © 2019 Christian Tietze. All rights reserved. Distributed under the MIT License. 4 | 5 | import PackageDescription 6 | 7 | let package = Package( 8 | name: "CrashReporter", 9 | platforms: [ 10 | .macOS(.v10_11) 11 | ], 12 | products: [ 13 | .library(name: "CrashReporter", targets: ["CrashReporter"]) 14 | ], 15 | targets: [ 16 | .target(name: "CrashReporter"), 17 | .testTarget( 18 | name: "CrashReporterTests", 19 | dependencies: ["CrashReporter"] 20 | ) 21 | ] 22 | ) 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CrashReporter for macOS Apps 2 | 3 | [![CI Status](https://img.shields.io/travis/CleanCocoa/CrashReporter.svg?style=flat)](https://travis-ci.org/CleanCocoa/CrashReporter) 4 | ![Swift 5.0](https://img.shields.io/badge/Swift-5.0-blue.svg?style=flat) 5 | ![Version](https://img.shields.io/github/tag/CleanCocoa/CrashReporter.svg?style=flat) 6 | ![License](https://img.shields.io/github/license/CleanCocoa/CrashReporter.svg?style=flat) 7 | ![Platform](https://img.shields.io/badge/platform-macOS-lightgrey.svg?style=flat) 8 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 9 | 10 | Your app will crash one day. Be prepared to collect crash data automatically, because not every user is a techno wizard capable of sending you `.crash` files from the built-in Console app. 11 | 12 |
13 | 14 | 15 |
16 | 17 | ## Requirements 18 | 19 | - macOS 10.12+ 20 | - Xcode 10.2+ 21 | - Swift 5+ 22 | 23 | For the optional server endpoint script, you'll need PHP 7.x. 24 | 25 | 26 | ## Installation 27 | 28 | ### Carthage 29 | 30 | github "CleanCocoa/CrashReporter" 31 | 32 | ### CocoaPods 33 | 34 | pod 'CrashReporterMac' 35 | 36 | ### SwiftPM 37 | 38 | .package(url: "https://github.com/CleanCocoa/CrashReporter", from: "0.2.0") 39 | 40 | ### Manual 41 | 42 | If you want to customize the UI, checkout the source and copy all code from `CrashReporter/` into your project. 43 | 44 | 45 | ## Usage 46 | 47 | ### Server Endpoint 48 | 49 | You need a server endpoint to receive crash reports. 50 | 51 | The framework does not care what the server does: 52 | 53 | - You can email the incoming crash report from your server, or 54 | - you can store the crash report as a timestamped file on disk for later reference, of 55 | - you can store the crash report in a database. 56 | 57 | The crash reporter framework will perform a HTTP POST request: 58 | 59 | - The `User-Agent` metadata is set to `"\(APP_NAME)-\(VERSION)"` if the values are found in the app's bundle, e.g. `"Sherlock-2.0"`. 60 | - The `userEmail` variable is either left out or set to the email entered by the user. 61 | - The `userProvidedDetails` variable is either left out or set to the details entered by the user. 62 | - The `crashlog` variable is set to the contents of the `.crash` file the user submits. 63 | - The server response will be ignored. 64 | 65 | You can roll your own endpoint as long as its URL is reachable from the app. 66 | 67 | Or you can use the simple endpoint shipped in this repository! It's located at `php/index.php`. This PHP server script will attempt to email you the crash log as an attachment with a timestamp, e.g. `20190701204853 Sherlock-2.0.crash` (where the timestamp signifies the ISO-formatted date 2019-07-01 20:48:52). If the user enters her email address, she'll receive a copy as CC by default. You can toggle this in the PHP script's frontmatter. 68 | 69 | To run the script on your local machine for quick testing, run: 70 | 71 | $ php -S 127.0.0.1:3333 php/index.php 72 | 73 | Then use `URL(string: "http://127.0.0.1:3333/")` in your Swift code for the endpoint. 74 | 75 | 76 | ### Application Setup 77 | 78 | See the code in `Example/`, which is part of the Xcode project. 79 | 80 | You can use the framework as-is in your app to check for crash reports: 81 | 82 | ```swift 83 | import CrashReporter 84 | 85 | let crashReporterURL = URL(string: "http://127.0.0.1:3333/")! 86 | let crashReporter = CrashReporter( 87 | crashReporterURL: crashReporterURL, 88 | privacyPolicyURL: URL(string: "https://example.com/privacy-policy")!) 89 | 90 | // Run the check in the background and display 91 | // a crash reporter window if needed 92 | crashReporter.check() 93 | ``` 94 | 95 | 96 | ### Preference Pane in Your Application 97 | 98 | If you allow the user to tick "Send crash reports automatically" in the crash reporter window, you should add a similar option to your app's preference pane to enable undoing this setting. 99 | 100 | Refer to `DefaultsKeys.sendCrashLogsAutomaticallyKey`. 101 | 102 | If you want to employ Cocoa Bindings to configure a "Send crash reports automatically" checkbox in your preference panes or main menu, then you can create a simple KVC-compliant wrapper in your classes: 103 | 104 | ```swift 105 | // Assuming this is loaded from a Nib where you set an object of this type as the 106 | // target for "Value" Cocoa Bindings. 107 | class PreferenceController: NSViewController { 108 | let crashReporter: CrashReporter = // ... setup before ... 109 | 110 | // Cocoa bindings path is `self.sendCrashReportsAutomatically` 111 | @objc public dynamic var sendCrashReportsAutomatically: Bool { 112 | get { 113 | return crashReporter.sendCrashReportsAutomatically 114 | } 115 | set { 116 | crashReporter.sendCrashReportsAutomatically = newValue 117 | } 118 | } 119 | } 120 | ``` 121 | 122 | 123 | ## API 124 | 125 | - `CrashReporter.check()` is the default call that displays the crash reporter window for the current app if needed, and uploads the crash report to the server. 126 | - `CrashReporter.check(appName:collectEmailAddress:alwaysShowCrashReporterWindow:)` allows you to control the app name for which the reporter searches `.crash` files. Set `collectEmailAddress` to false if you don't want to collect the email address of the user to get back to them. Set `alwaysShowCrashReporterWindow` to `true` if you always want to show the crash reporter window instead of letting the user pick when she sees the window. 127 | - `CrashReporter.sendCrashReportsAutomatically` exposes the user setting of sending reports automatically. Useful for preference panes. 128 | 129 | If you don't change the `UserDefaults` keys for the crash reporter settings, use the various `DefaultsKeys.standard` properties in your app to look up the values: 130 | 131 | - `emailAddressKey` is `"CRR_emailAddress"`, where the email address of the user is stored 132 | - `sendCrashLogsAutomaticallyKey` is `"CRR_sendCrashLogsAutomatically"` -- use this for your preference panes to toggle automatically sending crash reports 133 | - `lastSeenCrashLogTimeSince1970Key` is `"CRR_lastSeenCrashLogTimeSince1970"` 134 | - `lastSeenCrashLogMD5Key` is `"CRR_lastSeenCrashLogMD5"` 135 | 136 | 137 | ## License 138 | 139 | The whole project is distributed under the MIT license. See [the LICENSE file](LICENSE) for reference. 140 | 141 | A quick overview: 142 | 143 | - The Swift code is adapted from [Brent Simmons's NetNewsWire 5](https://github.com/brentsimmons/NetNewsWire), Copyright © Brent Simmons 2017-2019. All rights reserved. 144 | - Changes in this repository are Copyright © Christian Tietze 2019. All rights reserved. 145 | - The PHP server code is Copyright © Christian Tietze 2019. All rights reserved. 146 | 147 | -------------------------------------------------------------------------------- /Sources/CrashReporter/CrashLog.swift: -------------------------------------------------------------------------------- 1 | // Part of 2 | // 3 | // Created by Brent Simmons on 12/17/18. 4 | // Copyright © 2018 Ranchero Software. All rights reserved. 5 | // Copyright © 2019 Christian Tietze. All rights reserved. 6 | // Distributed under the MIT License. 7 | 8 | import struct Foundation.URL 9 | import struct Foundation.Date 10 | import class Foundation.NSString 11 | 12 | struct CrashLog { 13 | let url: URL 14 | let modificationDate: Date 15 | let content: String 16 | let contentHash: String 17 | 18 | init(url: URL, modificationDate: Date, content: String, contentHash: String) { 19 | self.url = url 20 | self.modificationDate = modificationDate 21 | self.content = content 22 | self.contentHash = contentHash 23 | } 24 | } 25 | 26 | extension CrashLog { 27 | init?(url: URL, modificationDate: Date) { 28 | guard let contents = try? String(contentsOf: url) else { return nil } 29 | guard !contents.isEmpty else { return nil } 30 | 31 | self.init( 32 | url: url, 33 | modificationDate: modificationDate, 34 | content: contents, 35 | contentHash: contents.md5) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Sources/CrashReporter/CrashReporter+DefaultsKeys.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | extension CrashReporter { 5 | /// Definition of the UserDefaults keys to use. 6 | public struct DefaultsKeys { 7 | public static var standard: DefaultsKeys { 8 | return DefaultsKeys( 9 | emailAddressKey: "CRR_emailAddress", 10 | sendCrashLogsAutomaticallyKey: "CRR_sendCrashLogsAutomatically", 11 | lastSeenCrashLogTimeSince1970Key: "CRR_lastSeenCrashLogTimeSince1970", 12 | lastSeenCrashLogMD5Key: "CRR_lastSeenCrashLogMD5") 13 | } 14 | 15 | public let emailAddressKey: String 16 | public let sendCrashLogsAutomaticallyKey: String 17 | public let lastSeenCrashLogTimeSince1970Key: String 18 | public let lastSeenCrashLogMD5Key: String 19 | 20 | public init( 21 | emailAddressKey: String, 22 | sendCrashLogsAutomaticallyKey: String, 23 | lastSeenCrashLogTimeSince1970Key: String, 24 | lastSeenCrashLogMD5Key: String) { 25 | 26 | self.emailAddressKey = emailAddressKey 27 | self.sendCrashLogsAutomaticallyKey = sendCrashLogsAutomaticallyKey 28 | self.lastSeenCrashLogTimeSince1970Key = lastSeenCrashLogTimeSince1970Key 29 | self.lastSeenCrashLogMD5Key = lastSeenCrashLogMD5Key 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Sources/CrashReporter/CrashReporter.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | #import 5 | 6 | //! Project version number for CrashReporter. 7 | FOUNDATION_EXPORT double CrashReporterVersionNumber; 8 | 9 | //! Project version string for CrashReporter. 10 | FOUNDATION_EXPORT const unsigned char CrashReporterVersionString[]; 11 | 12 | // In this header, you should import all the public headers of your framework using statements like #import 13 | 14 | 15 | -------------------------------------------------------------------------------- /Sources/CrashReporter/CrashReporter.swift: -------------------------------------------------------------------------------- 1 | // Part of 2 | // 3 | // Created by Brent Simmons on 12/17/18. 4 | // Copyright © 2018 Ranchero Software. All rights reserved. 5 | // Copyright © 2019 Christian Tietze. All rights reserved. 6 | // Distributed under the MIT License. 7 | 8 | import AppKit 9 | 10 | public final class CrashReporter { 11 | 12 | public let crashReporterURL: URL 13 | public let privacyPolicyURL: URL 14 | public let userDefaults: UserDefaults 15 | public let defaultsKeys: DefaultsKeys 16 | 17 | /// Convenience accessor for `sendCrashLogsAutomaticallyKey` defaults. 18 | /// 19 | /// Can be wrapped for KVC/Cocoa bindings in your preference panes when you access it through 20 | /// a property wrapping it as a `@objc dynamic var`: 21 | /// 22 | /// let var crashReporter = // ... 23 | /// 24 | /// @objc dynamic var sendCrashReportsAutomatically: Bool { 25 | /// get { 26 | /// return crashReporter.sendCrashReportsAutomatically 27 | /// } 28 | /// set { 29 | /// crashReporter.sendCrashReportsAutomatically = newValue 30 | /// } 31 | /// } 32 | /// 33 | public var sendCrashReportsAutomatically: Bool { 34 | get { 35 | return userDefaults.bool(forKey: defaultsKeys.sendCrashLogsAutomaticallyKey) 36 | } 37 | set { 38 | userDefaults.set(newValue, forKey: defaultsKeys.sendCrashLogsAutomaticallyKey) 39 | } 40 | } 41 | 42 | /// - param crashReporterURL: Server endpoint to send the crash log to. 43 | /// - param privacyPolicyURL: Web address that points to your privacy policy with details on how you handle crash log data. 44 | /// - param userDefaults: `UserDefaults` to store the last crash info in. Useful for defaults in app groups. Default is `UserDefaults.standard`. 45 | /// - param defaultsKeys: Configuration of the defaults keys to use. Default is `DefaultsKeys.standard`. 46 | public init( 47 | crashReporterURL: URL, 48 | privacyPolicyURL: URL, 49 | userDefaults: UserDefaults = .standard, 50 | defaultsKeys: DefaultsKeys = DefaultsKeys.standard) { 51 | self.crashReporterURL = crashReporterURL 52 | self.privacyPolicyURL = privacyPolicyURL 53 | self.userDefaults = userDefaults 54 | self.defaultsKeys = defaultsKeys 55 | } 56 | 57 | // MARK: - Testing seams 58 | 59 | /// Testing seam reading the `lastSeenCrashLogTimeSince1970Key` from user defaults. 60 | internal var lastSeenCrashLogDate: Date { 61 | return Date(timeIntervalSince1970: userDefaults.double(forKey: defaultsKeys.lastSeenCrashLogTimeSince1970Key)) 62 | } 63 | 64 | /// Testing seam reading the `sendCrashLogsAutomaticallyKey` from user defaults. 65 | internal var shouldSendCrashLogsAutomatically: Bool { 66 | return userDefaults.bool(forKey: defaultsKeys.sendCrashLogsAutomaticallyKey) 67 | } 68 | 69 | /// Testing seam reading the `lastSeenCrashLogMD5Key` from user defaults. 70 | internal var lastSeenCrashLogMD5Hash: String? { 71 | return userDefaults.string(forKey: defaultsKeys.lastSeenCrashLogMD5Key) 72 | } 73 | 74 | /// Testing seam and configuration option to fetch reports. 75 | /// Default is `"~/Library/Logs/DiagnosticReports/"` 76 | internal lazy var crashReportFolderURL: URL = self.fileManager.diagnosticsReportsFolderURL 77 | 78 | /// Testing seam. 79 | internal var fileManager: FileManager { 80 | return .default 81 | } 82 | 83 | // MARK: - Check for crashes 84 | 85 | /// Look in ~/Library/Logs/DiagnosticReports/ for a new crash log for this app. 86 | /// 87 | /// Checks for crashes using the `CFBundleName` from the main app bundle as `appName`. 88 | /// 89 | /// - Parameters: 90 | /// - collectEmailAddress: Ask users for their email addresses when sending in reports. Default is true. 91 | /// - alwaysShowCrashReporterWindow: Overrides the user setting `shouldSendCrashLogsAutomaticallyKey`. Default is false. 92 | /// - displayCrashReporterWindowAsModal: Whether to show the window on top of other app windows. Default is false. 93 | /// - Note: When `collectEmailAddress` is disabled, you will not even get previously stored value from user defaults. 94 | public func check(collectEmailAddress: Bool = true, 95 | alwaysShowCrashReporterWindow: Bool = false, 96 | displayCrashReporterWindowAsModal: Bool = false) { 97 | self.check( 98 | appName: Bundle.main.infos[.bundleName]!, 99 | collectEmailAddress: collectEmailAddress, 100 | alwaysShowCrashReporterWindow: alwaysShowCrashReporterWindow, 101 | displayCrashReporterWindowAsModal: displayCrashReporterWindowAsModal) 102 | } 103 | 104 | /// Look in ~/Library/Logs/DiagnosticReports/ for a new crash log for `appName`. 105 | /// 106 | /// If a new crash log was found, show the reporter window or automatically 107 | /// upload the report, depending on the `shouldSendCrashLogsAutomaticallyKey`. 108 | /// Set `alwaysShowCrashReporterWindow` to override this behavior. 109 | /// 110 | /// - Parameters: 111 | /// - appName: Name of the application to search recent crash reports for. 112 | /// - collectEmailAddress: Ask users for their email addresses when sending in reports. Default is true. 113 | /// - alwaysShowCrashReporterWindow: Overrides the user setting `shouldSendCrashLogsAutomaticallyKey`. Default is false. 114 | /// - displayCrashReporterWindowAsModal: Whether to show the window on top of other app windows. Default is false. 115 | /// - Note: When `collectEmailAddress` is disabled, you will not even get previously stored value from user defaults. 116 | public func check(appName: String, 117 | collectEmailAddress: Bool = true, 118 | alwaysShowCrashReporterWindow: Bool = false, 119 | displayCrashReporterWindowAsModal: Bool = false) { 120 | guard let crashLog = mostRecentCrashInfo(appName: appName)?.crashLog() else { return } 121 | 122 | if hasSeen(crashLog) { 123 | return 124 | } 125 | remember(crashLog) 126 | 127 | if shouldSendCrashLogsAutomatically && alwaysShowCrashReporterWindow == false { 128 | let emailSetting = EmailAddressSetting(isVisible: false, userDefaults: self.userDefaults, emailAddressKey: self.defaultsKeys.emailAddressKey) 129 | let emailAddress = collectEmailAddress ? emailSetting.emailAddress : nil 130 | send(emailAddress: emailAddress, userProvidedDetails: nil, crashLogText: crashLog.content) 131 | } else { 132 | runCrashReporterWindow( 133 | appName: appName, 134 | crashLog: crashLog, 135 | displayAsModal: displayCrashReporterWindowAsModal, 136 | hideEmailCollection: !collectEmailAddress, 137 | hideSendReportsAutomaticallyOption: alwaysShowCrashReporterWindow) 138 | } 139 | } 140 | 141 | internal func mostRecentCrashInfo(appName: String) -> CrashInfo? { 142 | guard let fileURLs = try? allCrashReportFolderFiles() else { return nil } 143 | 144 | let relevantCrashInfos: [CrashInfo] = fileURLs 145 | .filter(matches(appName: appName)) 146 | .compactMap { CrashInfo(url: $0, fileManager: fileManager) } 147 | .filter(newerThan(lastSeenCrashLogDate)) 148 | 149 | return findMostRecent(crashInfos: relevantCrashInfos) 150 | } 151 | 152 | internal func allCrashReportFolderFiles() throws -> [URL] { 153 | return try fileManager.contentsOfDirectory( 154 | at: crashReportFolderURL, 155 | includingPropertiesForKeys: nil, 156 | options: []) 157 | } 158 | 159 | internal var crashReportWindowController: CrashReportWindowController? 160 | 161 | internal func runCrashReporterWindow( 162 | appName: String, 163 | crashLog: CrashLog, 164 | displayAsModal: Bool, 165 | hideEmailCollection: Bool, 166 | hideSendReportsAutomaticallyOption: Bool) { 167 | let collectEmailSetting = EmailAddressSetting( 168 | isVisible: !hideEmailCollection, 169 | userDefaults: self.userDefaults, 170 | emailAddressKey: self.defaultsKeys.emailAddressKey) 171 | let sendAutomaticallySetting = SendReportsAutomaticallySetting( 172 | isVisible: !hideSendReportsAutomaticallyOption, 173 | userDefaults: self.userDefaults, 174 | sendCrashLogsAutomaticallyKey: self.defaultsKeys.sendCrashLogsAutomaticallyKey) 175 | 176 | self.crashReportWindowController = CrashReportWindowController( 177 | appName: appName, 178 | crashLogText: crashLog.content, 179 | // Produces a retain cycle that we'll break when the window closes: 180 | crashLogSender: self, 181 | privacyPolicyURL: self.privacyPolicyURL, 182 | collectEmailSetting: collectEmailSetting, 183 | sendReportsAutomaticallySetting: sendAutomaticallySetting) 184 | 185 | // Drop reference to window after closing to eventually free memory. 186 | // Call this before potentially making the window run in a modal loop. 187 | self.crashReportWindowController?.onWindowWillClose = { [unowned self] _ in 188 | if displayAsModal { 189 | NSApp.stopModal() 190 | } 191 | self.crashReportWindowController = nil 192 | } 193 | 194 | self.crashReportWindowController?.showWindow(self) 195 | self.crashReportWindowController?.window?.makeKeyAndOrderFront(self) 196 | 197 | if displayAsModal, 198 | let window = self.crashReportWindowController?.window { 199 | NSApp.runModal(for: window) 200 | } 201 | } 202 | 203 | internal func hasSeen(_ crashLog: CrashLog) -> Bool { 204 | // No need to compare dates, because that's done in the file loop. 205 | // Check to see if we've already reported this exact crash log. 206 | return crashLog.contentHash == self.lastSeenCrashLogMD5Hash 207 | } 208 | 209 | internal func remember(_ crashLog: CrashLog) { 210 | userDefaults.set(crashLog.contentHash, forKey: defaultsKeys.lastSeenCrashLogMD5Key) 211 | userDefaults.set(crashLog.modificationDate.timeIntervalSince1970, forKey: defaultsKeys.lastSeenCrashLogTimeSince1970Key) 212 | } 213 | } 214 | 215 | // MARK: - SendsCrashLog 216 | 217 | extension CrashReporter: SendsCrashLog { 218 | internal func send(emailAddress: String?, userProvidedDetails: String?, crashLogText: String) { 219 | var request = URLRequest(url: self.crashReporterURL) 220 | request.httpMethod = "POST" 221 | 222 | let boundary = UUID().uuidString.md5 223 | 224 | let contentType = "multipart/form-data; boundary=\(boundary)" 225 | request.setValue(contentType, forHTTPHeaderField: "Content-Type") 226 | 227 | let form: [String : String?] = [ 228 | "userEmail" : emailAddress, 229 | "userProvidedDetails": userProvidedDetails, 230 | "crashlog" : crashLogText 231 | ] 232 | // See for a specification. 233 | // Example: 234 | // Content-Type: multipart/form-data; boundary=AaB03x 235 | // 236 | // --AaB03x 237 | // Content-Disposition: form-data; name="submit-name" 238 | // 239 | // Larry 240 | // --AaB03x 241 | // Content-Disposition: form-data; name="files"; filename="file1.txt" 242 | // Content-Type: text/plain 243 | // 244 | // ... contents of file1.txt ... 245 | // --AaB03x-- 246 | let CRLF = "\r\n" 247 | let separator = "--\(boundary)" + CRLF 248 | let terminator = "--\(boundary)--" + CRLF 249 | let formString = 250 | separator 251 | + form.compactMap { key, value -> String? in 252 | guard let value = value, !value.isEmpty else { return nil } 253 | let lines = [ 254 | "Content-Disposition: form-data; name=\"\(key)\"", 255 | "", // Key and value are separated by an empty line 256 | value 257 | ] 258 | return lines.joined(separator: "\r\n") + CRLF 259 | }.joined(separator: separator) + CRLF 260 | + terminator 261 | let formData = formString.data(using: .utf8, allowLossyConversion: true) 262 | request.httpBody = formData 263 | 264 | download(request) { (data, response, error) in 265 | // Ignore result of the upload. 266 | // Uncomment to debug the server response: 267 | //print(response, data.flatMap { String(data: $0, encoding: .utf8) }) 268 | return 269 | } 270 | } 271 | } 272 | 273 | // MARK: - Crash report file metadata 274 | 275 | internal struct CrashInfo { 276 | let url: URL 277 | let date: Date 278 | 279 | init(url: URL, date: Date) { 280 | self.url = url 281 | self.date = date 282 | } 283 | 284 | func crashLog() -> CrashLog? { 285 | return CrashLog(url: url, modificationDate: date) 286 | } 287 | } 288 | 289 | extension CrashInfo { 290 | init?(url: URL, fileManager: FileManager) { 291 | self.init( 292 | url: url, 293 | getModificationDate: fileManager.fileModificationDate(url:)) 294 | } 295 | 296 | init?(url: URL, getModificationDate: (URL) -> Date? = FileManager.default.fileModificationDate(url:)) { 297 | guard let modificationDate = getModificationDate(url) else { return nil} 298 | self.init(url: url, date: modificationDate) 299 | } 300 | } 301 | 302 | extension FileManager { 303 | fileprivate func fileModificationDate(url: URL) -> Date? { 304 | let fileAttributes: [FileAttributeKey: Any] = (try? self.attributesOfItem(atPath: url.path)) ?? [:] 305 | return fileAttributes[.modificationDate] as? Date 306 | } 307 | 308 | fileprivate var diagnosticsReportsFolderURL: URL { 309 | let homeDirectory: URL 310 | 311 | if #available(OSX 10.12, *) { 312 | homeDirectory = self.homeDirectoryForCurrentUser 313 | } else { 314 | homeDirectory = URL(fileURLWithPath: ("~" as NSString).expandingTildeInPath) 315 | } 316 | 317 | return homeDirectory 318 | .appendingPathComponent("Library") 319 | .appendingPathComponent("Logs") 320 | .appendingPathComponent("DiagnosticReports") 321 | } 322 | } 323 | 324 | fileprivate func newerThan(_ referenceDate: Date) -> (_ crashInfo: CrashInfo) -> Bool { 325 | return { crashInfo in 326 | crashInfo.date > referenceDate 327 | } 328 | } 329 | 330 | fileprivate func matches(appName: String) -> (_ url: URL) -> Bool { 331 | let lowerAppName = appName.lowercased() 332 | 333 | var crashSuffixes: [String] = [".crash"] 334 | if #available(macOS 12, *) { 335 | crashSuffixes.append(".ips") 336 | } 337 | 338 | return { url in 339 | let filename = url.lastPathComponent 340 | return filename.lowercased().hasPrefix(lowerAppName) 341 | && crashSuffixes.contains { filename.hasSuffix($0) } 342 | } 343 | } 344 | 345 | fileprivate func findMostRecent(crashInfos: [CrashInfo]) -> CrashInfo? { 346 | // Pairwise comparison; returns the most recent of the two. 347 | func moreRecent(_ lhs: CrashInfo?, _ rhs: CrashInfo) -> CrashInfo { 348 | guard let lhs = lhs else { 349 | return rhs 350 | } 351 | if lhs.date > rhs.date { 352 | return lhs 353 | } 354 | return rhs 355 | } 356 | 357 | return crashInfos.reduce(nil) { (mostRecent: CrashInfo?, next: CrashInfo) -> CrashInfo? in 358 | return moreRecent(mostRecent, next) 359 | } 360 | } 361 | -------------------------------------------------------------------------------- /Sources/CrashReporter/CrashReporterBundle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CrashReporterBundle.swift 3 | // CrashReporter 4 | // 5 | // Created by Nathan Manceaux-Panot on 2024-11-16. 6 | // 7 | 8 | import Foundation 9 | 10 | let CrashReporterBundle: Bundle = { 11 | #if SWIFT_PACKAGE 12 | return Bundle.module 13 | #else 14 | return Bundle.main 15 | #endif 16 | }() 17 | -------------------------------------------------------------------------------- /Sources/CrashReporter/EmailAddressSetting.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2020 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | import Foundation 5 | 6 | struct EmailAddressSetting { 7 | static var standard: EmailAddressSetting { 8 | return EmailAddressSetting( 9 | isVisible: true, 10 | userDefaults: .standard, 11 | emailAddressKey: CrashReporter.DefaultsKeys.standard.emailAddressKey) 12 | } 13 | 14 | let isVisible: Bool 15 | 16 | let userDefaults: UserDefaults 17 | let emailAddressKey: String 18 | 19 | var emailAddress: String? { 20 | get { 21 | return userDefaults.string(forKey: emailAddressKey) 22 | } 23 | set { 24 | userDefaults.set(newValue, forKey: emailAddressKey) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sources/CrashReporter/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.2.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSHumanReadableCopyright 22 | Copyright © 2019 Christian Tietze. All rights reserved. 23 | 24 | 25 | -------------------------------------------------------------------------------- /Sources/CrashReporter/Infrastructure/Bundle+InfoKeys.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | import Foundation 5 | 6 | internal struct InfoPlistKey: RawRepresentable { 7 | internal var rawValue: String 8 | 9 | internal init(rawValue: String) { 10 | self.rawValue = rawValue 11 | } 12 | 13 | internal static let build = InfoPlistKey(rawValue: "CFBundleVersion") 14 | internal static let version = InfoPlistKey(rawValue: "CFBundleShortVersionString") 15 | 16 | internal static let bundleName = InfoPlistKey(rawValue: "CFBundleName") 17 | internal static let bundleIdentifier = InfoPlistKey(rawValue: "CFBundleIdentifier") 18 | } 19 | 20 | extension Bundle { 21 | internal var infos: Infos { 22 | return Infos(dictionary: infoDictionary) 23 | } 24 | 25 | internal struct Infos { 26 | let dictionary: [String : Any]? 27 | internal subscript(_ key: InfoPlistKey) -> String? { 28 | return dictionary?[key.rawValue] as? String 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sources/CrashReporter/Infrastructure/HTTPURLResponse+valueForHTTPHeaderField.swift: -------------------------------------------------------------------------------- 1 | // Part of 2 | // 3 | // Created by Brent Simmons on 8/14/16. 4 | // Copyright © 2016 Ranchero Software, LLC. All rights reserved. 5 | // Copyright © 2019 Christian Tietze. All rights reserved. 6 | // Distributed under the MIT License. 7 | 8 | import class Foundation.HTTPURLResponse 9 | 10 | extension HTTPURLResponse { 11 | /// Case-insensitive. HTTP headers may not be in the case you expect. 12 | internal func valueForHTTPHeaderField(_ headerField: String) -> String? { 13 | let lowerHeaderField = headerField.lowercased() 14 | 15 | for (key, value) in allHeaderFields { 16 | if lowerHeaderField == (key as? String)?.lowercased() { 17 | return value as? String 18 | } 19 | } 20 | 21 | return nil 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/CrashReporter/Infrastructure/OneShotDownload.swift: -------------------------------------------------------------------------------- 1 | // Part of 2 | // 3 | // Created by Brent Simmons on 8/27/16. 4 | // Copyright © 2016 Ranchero Software, LLC. All rights reserved. 5 | // Copyright © 2019 Christian Tietze. All rights reserved. 6 | // Distributed under the MIT License. 7 | 8 | import Foundation 9 | 10 | internal typealias OneShotDownloadCallback = (Data?, URLResponse?, Error?) -> Swift.Void 11 | 12 | private final class OneShotDownloadManager { 13 | 14 | private let urlSession: URLSession 15 | fileprivate static let shared = OneShotDownloadManager() 16 | 17 | init() { 18 | 19 | let sessionConfiguration = URLSessionConfiguration.ephemeral 20 | sessionConfiguration.requestCachePolicy = .reloadIgnoringLocalCacheData 21 | sessionConfiguration.httpShouldSetCookies = false 22 | sessionConfiguration.httpCookieAcceptPolicy = .never 23 | sessionConfiguration.httpMaximumConnectionsPerHost = 2 24 | sessionConfiguration.httpCookieStorage = nil 25 | sessionConfiguration.urlCache = nil 26 | sessionConfiguration.timeoutIntervalForRequest = 30 27 | 28 | if let appName = Bundle.main.infos[.bundleName], 29 | let version = Bundle.main.infos[.version] { 30 | sessionConfiguration.httpAdditionalHeaders = ["User-Agent" : "\(appName)-\(version)"] 31 | } 32 | 33 | urlSession = URLSession(configuration: sessionConfiguration) 34 | } 35 | 36 | deinit { 37 | urlSession.invalidateAndCancel() 38 | } 39 | 40 | func download(_ url: URL, _ callback: @escaping OneShotDownloadCallback) { 41 | let task = urlSession.dataTask(with: url) { (data, response, error) in 42 | DispatchQueue.main.async() { 43 | callback(data, response, error) 44 | } 45 | } 46 | task.resume() 47 | } 48 | 49 | func download(_ urlRequest: URLRequest, _ callback: @escaping OneShotDownloadCallback) { 50 | let task = urlSession.dataTask(with: urlRequest) { (data, response, error) in 51 | DispatchQueue.main.async() { 52 | callback(data, response, error) 53 | } 54 | } 55 | task.resume() 56 | } 57 | } 58 | 59 | // Call one of these. It’s easier than referring to OneShotDownloadManager. 60 | // callback is called on the main queue. 61 | 62 | internal func download(_ url: URL, _ callback: @escaping OneShotDownloadCallback) { 63 | precondition(Thread.isMainThread) 64 | OneShotDownloadManager.shared.download(url, callback) 65 | } 66 | 67 | internal func download(_ urlRequest: URLRequest, _ callback: @escaping OneShotDownloadCallback) { 68 | precondition(Thread.isMainThread) 69 | OneShotDownloadManager.shared.download(urlRequest, callback) 70 | } 71 | -------------------------------------------------------------------------------- /Sources/CrashReporter/Infrastructure/String+md5.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | import Foundation 5 | import CommonCrypto 6 | 7 | // For iOS 13 and macOS 10.15, we can eventually switch to CryptoKit: 8 | // https://developer.apple.com/documentation/cryptokit 9 | 10 | extension String { 11 | /// Computes a MD5 hash from the recipient. 12 | /// Implementation based on 13 | internal var md5: String { 14 | let length = Int(CC_MD5_DIGEST_LENGTH) 15 | let messageData = self.data(using: .utf8)! 16 | var digestData = Data(count: length) 17 | 18 | digestData.withUnsafeMutableBytes { digestBytes -> Void in 19 | messageData.withUnsafeBytes { messageBytes -> Void in 20 | guard let messageBytesBaseAddress = messageBytes.baseAddress else { return } 21 | guard let digestBytesBlindMemory = digestBytes.bindMemory(to: UInt8.self).baseAddress else { return } 22 | let messageLength = CC_LONG(messageData.count) 23 | CC_MD5(messageBytesBaseAddress, messageLength, digestBytesBlindMemory) 24 | } 25 | } 26 | 27 | return digestData.map { String(format: "%02hhx", $0) }.joined() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/CrashReporter/Infrastructure/URLResponse+statusIsOK.swift: -------------------------------------------------------------------------------- 1 | // Part of 2 | // 3 | // Created by Brent Simmons on 8/14/16. 4 | // Copyright © 2016 Ranchero Software, LLC. All rights reserved. 5 | // Copyright © 2019 Christian Tietze. All rights reserved. 6 | // Distributed under the MIT License. 7 | 8 | import class Foundation.URLResponse 9 | import class Foundation.HTTPURLResponse 10 | 11 | extension URLResponse { 12 | internal var statusIsOK: Bool { 13 | guard let response = self as? HTTPURLResponse else { return false } 14 | return (200...299).contains(response.statusCode) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Sources/CrashReporter/SendReportsAutomaticallySetting.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | import Foundation 5 | 6 | struct SendReportsAutomaticallySetting { 7 | static var standard: SendReportsAutomaticallySetting { 8 | return SendReportsAutomaticallySetting( 9 | isVisible: true, 10 | userDefaults: .standard, 11 | sendCrashLogsAutomaticallyKey: CrashReporter.DefaultsKeys.standard.sendCrashLogsAutomaticallyKey) 12 | } 13 | 14 | let isVisible: Bool 15 | 16 | let userDefaults: UserDefaults 17 | let sendCrashLogsAutomaticallyKey: String 18 | 19 | var isEnabled: Bool { 20 | get { 21 | return userDefaults.bool(forKey: sendCrashLogsAutomaticallyKey) 22 | } 23 | set { 24 | userDefaults.set(newValue, forKey: sendCrashLogsAutomaticallyKey) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sources/CrashReporter/UI/CrashReportWindowController.swift: -------------------------------------------------------------------------------- 1 | // Part of 2 | // 3 | // Created by Brent Simmons on 12/28/18. 4 | // Copyright © 2018 Ranchero Software. All rights reserved. 5 | // Copyright © 2019 Christian Tietze. All rights reserved. 6 | // Distributed under the MIT License. 7 | 8 | import AppKit 9 | 10 | protocol SendsCrashLog { 11 | func send(emailAddress: String?, userProvidedDetails: String?, crashLogText: String) 12 | } 13 | 14 | final class CrashReportWindowController: NSWindowController, NSWindowDelegate { 15 | 16 | convenience init( 17 | appName: String, 18 | crashLogText: String, 19 | crashLogSender: SendsCrashLog, 20 | privacyPolicyURL: URL, 21 | collectEmailSetting: EmailAddressSetting, 22 | sendReportsAutomaticallySetting: SendReportsAutomaticallySetting 23 | ) { 24 | self.init() 25 | 26 | var nibTopLevelObjects: NSArray? 27 | CrashReporterBundle.loadNibNamed( 28 | "CrashReporterWindow", owner: self, topLevelObjects: &nibTopLevelObjects) 29 | self.window = nibTopLevelObjects?.lazy.compactMap({ $0 as? NSWindow }).first 30 | 31 | self.crashLogText = crashLogText 32 | self.crashLogSender = crashLogSender 33 | self.privacyPolicyURL = privacyPolicyURL 34 | self.collectEmailSetting = collectEmailSetting 35 | self.sendReportsAutomaticallySetting = sendReportsAutomaticallySetting 36 | 37 | // Setup window 38 | window?.center() 39 | window?.delegate = self 40 | 41 | window?.title = "\(appName) Crash Reporter" 42 | titleLabel.stringValue = "\(appName) quit unexpectedly." 43 | crashLogContainerView.isHidden = true 44 | 45 | updateCrashLogText() 46 | updateCollectEmailVisibility() 47 | updateAutomaticallySendCrashLogVisibility() 48 | updateButtonStates() 49 | } 50 | 51 | var onWindowWillClose: ((NSWindow?) -> Void)? 52 | 53 | func windowWillClose(_ notification: Notification) { 54 | onWindowWillClose?(notification.object as? NSWindow) 55 | } 56 | 57 | // MARK: View components 58 | 59 | @IBOutlet var textView: NSTextView! { 60 | didSet { 61 | textView.font = NSFont.userFixedPitchFont(ofSize: 0.0) 62 | textView.textContainerInset = NSSize(width: 5.0, height: 5.0) 63 | updateCrashLogText() 64 | } 65 | } 66 | 67 | @IBOutlet var titleLabel: NSTextField! 68 | @IBOutlet var bodyLabel: NSTextField! 69 | 70 | @IBOutlet weak var collectEmailContainerView: NSView! 71 | @IBOutlet weak var crashLogContainerView: NSView! 72 | @IBOutlet weak var sendAutomaticallyContainerView: NSView! 73 | 74 | @IBOutlet var sendCrashLogButton: NSButton! 75 | @IBOutlet var dontSendButton: NSButton! 76 | @IBOutlet var toggleCrashLogButton: NSButton! 77 | 78 | private func updateCrashLogText() { 79 | guard let textView = self.textView else { return } 80 | textView.string = crashLogText ?? "" 81 | } 82 | 83 | private func updateButtonStates() { 84 | sendCrashLogButton?.isEnabled = (crashLogSender != nil) && !didSendCrashLog 85 | dontSendButton?.isEnabled = !didSendCrashLog 86 | } 87 | 88 | private func updateCollectEmailVisibility() { 89 | collectEmailContainerView.isHidden = self.hideCollectEmail 90 | bodyLabel.stringValue = 91 | "Help us fix crashes by submitting this crash report." 92 | + (self.hideCollectEmail 93 | ? "" 94 | : " You can include your email address if you agree to being contacted for more details.") 95 | } 96 | 97 | private func updateAutomaticallySendCrashLogVisibility() { 98 | sendAutomaticallyContainerView.isHidden = self.hideAutomaticallySend 99 | } 100 | 101 | // MARK: Model 102 | 103 | internal var collectEmailSetting: EmailAddressSetting = .standard { 104 | didSet { 105 | updateCollectEmailVisibility() 106 | } 107 | } 108 | 109 | internal var hideCollectEmail: Bool { 110 | return !collectEmailSetting.isVisible 111 | } 112 | 113 | internal var sendReportsAutomaticallySetting: SendReportsAutomaticallySetting = .standard { 114 | didSet { 115 | updateAutomaticallySendCrashLogVisibility() 116 | } 117 | } 118 | 119 | internal var hideAutomaticallySend: Bool { 120 | return !sendReportsAutomaticallySetting.isVisible 121 | } 122 | 123 | /// KVC wrapper for `sendReportsAutomaticallySetting.isEnabled` 124 | @objc dynamic var sendCrashReportsAutomatically: Bool { 125 | get { 126 | return sendReportsAutomaticallySetting.isEnabled 127 | } 128 | set { 129 | sendReportsAutomaticallySetting.isEnabled = newValue 130 | } 131 | } 132 | 133 | /// KVC wrapper for `collectEmailSetting.emailAddress` 134 | @objc dynamic var emailAddress: String { 135 | get { 136 | return collectEmailSetting.emailAddress ?? "" 137 | } 138 | set { 139 | collectEmailSetting.emailAddress = newValue 140 | } 141 | } 142 | 143 | @objc dynamic var userProvidedDetails = "" 144 | 145 | internal var privacyPolicyURL: URL? 146 | 147 | internal var crashLogText: String? { 148 | didSet { 149 | updateCrashLogText() 150 | } 151 | } 152 | 153 | internal var crashLogSender: SendsCrashLog? { 154 | didSet { 155 | updateButtonStates() 156 | } 157 | } 158 | 159 | private var didSendCrashLog = false { 160 | didSet { 161 | updateButtonStates() 162 | } 163 | } 164 | 165 | // MARK: - User Interactions 166 | 167 | lazy var isRunningTests: Bool = false 168 | 169 | @IBAction func sendCrashReport(_ sender: Any?) { 170 | guard !didSendCrashLog else { return } 171 | defer { didSendCrashLog = true } 172 | 173 | if !isRunningTests, 174 | let crashLogText = self.crashLogText, 175 | let crashLogSender = self.crashLogSender 176 | { 177 | 178 | let emailAddress = self.collectEmailSetting.isVisible ? self.emailAddress : nil 179 | crashLogSender.send(emailAddress: emailAddress, userProvidedDetails: userProvidedDetails, crashLogText: crashLogText) 180 | } 181 | 182 | close() 183 | } 184 | 185 | @IBAction func dontSendCrashReport(_ sender: Any?) { 186 | close() 187 | } 188 | 189 | override func responds(to aSelector: Selector!) -> Bool { 190 | if aSelector == #selector(showPrivacyPolicy(_:)) { 191 | return self.privacyPolicyURL != nil 192 | } 193 | return super.responds(to: aSelector) 194 | } 195 | 196 | @IBAction func showPrivacyPolicy(_ sender: Any?) { 197 | guard let privacyPolicyURL = self.privacyPolicyURL else { return } 198 | NSWorkspace.shared.open(privacyPolicyURL) 199 | } 200 | 201 | @IBAction func toggleCrashLog(_ sender: Any?) { 202 | crashLogContainerView.isHidden = !crashLogContainerView.isHidden 203 | toggleCrashLogButton.title = 204 | crashLogContainerView.isHidden ? "Show Details" : "Hide Details" 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /Sources/CrashReporter/UI/CrashReporterWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Help us fix crashes by submitting this crash report. You can include your email address if you agree to being contacted for more details. 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | Your email address (optional) 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | Describe how the crash occurred (optional) 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 169 | 170 | 171 | 172 | 173 | 174 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 233 | 234 | 235 | 248 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | -------------------------------------------------------------------------------- /Tests/CrashReporterTests/EmailAddressSettingTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2020 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | import XCTest 5 | @testable import CrashReporter 6 | 7 | class EmailAddressSettingTests: XCTestCase { 8 | 9 | func testStandardReusesDefaultsKey() { 10 | XCTAssertEqual(EmailAddressSetting.standard.emailAddressKey, 11 | CrashReporter.DefaultsKeys.standard.emailAddressKey) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Tests/CrashReporterTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Tests/CrashReporterTests/SendReportsAutomaticallySettingTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. 2 | // Distributed under the MIT License. 3 | 4 | import XCTest 5 | @testable import CrashReporter 6 | 7 | class SendReportsAutomaticallySettingTests: XCTestCase { 8 | 9 | func testStandardReusesDefaultsKey() { 10 | XCTAssertEqual(SendReportsAutomaticallySetting.standard.sendCrashLogsAutomaticallyKey, 11 | CrashReporter.DefaultsKeys.standard.sendCrashLogsAutomaticallyKey) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /assets/reporter-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CleanCocoa/CrashReporter/30e31eac5cad1ec7f34330a3bd3feba14c357aec/assets/reporter-dark.png -------------------------------------------------------------------------------- /assets/reporter-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CleanCocoa/CrashReporter/30e31eac5cad1ec7f34330a3bd3feba14c357aec/assets/reporter-light.png -------------------------------------------------------------------------------- /php/index.php: -------------------------------------------------------------------------------- 1 | 33 | * 34 | *****************************************************************************/ 35 | 36 | 37 | use PHPMailer\PHPMailer\PHPMailer; 38 | use PHPMailer\PHPMailer\Exception; 39 | 40 | require 'vendor/PHPMailer/src/Exception.php'; 41 | require 'vendor/PHPMailer/src/PHPMailer.php'; 42 | require 'vendor/PHPMailer/src/SMTP.php'; 43 | 44 | function postString($key) { 45 | return array_key_exists($key, $_POST) ? $_POST[$key] : ''; 46 | } 47 | 48 | function clean($userData) { 49 | $userData = htmlspecialchars($userData, ENT_IGNORE, 'utf-8'); 50 | $userData = strip_tags($userData); 51 | $userData = trim($userData); 52 | return $userData; 53 | } 54 | 55 | function isEmpty($var) { 56 | return !isset($var) || strlen(trim($var)) == 0; 57 | } 58 | 59 | function sendEmailForReportAsFilenameForSender($path, $filename, $app, $userProvidedDetails = '', $userEmail = '') { 60 | $mail = new PHPMailer(true); 61 | 62 | //Server settings 63 | if (DEBUG) { 64 | $mail->Debugoutput = 'echo'; 65 | $mail->SMTPDebug = 4; 66 | } 67 | $mail->isSMTP(); 68 | $mail->Host = SMTP_HOST; 69 | $mail->SMTPAuth = True; 70 | $mail->Username = SMTP_USER; 71 | $mail->Password = SMTP_PASS; 72 | $mail->SMTPSecure = SMTP_SECURE; 73 | $mail->Port = SMTP_PORT; 74 | 75 | //Recipients 76 | $mail->setFrom(SENDER_EMAIL, SENDER_NAME); 77 | $mail->addAddress(SUPPORT_EMAIL, SUPPORT_NAME); 78 | if (!isEmpty($userEmail) && SEND_CC_TO_USER) { 79 | $mail->addCC($userEmail); 80 | } 81 | 82 | // Attachments 83 | $mail->addAttachment($path, $filename); 84 | 85 | // Content 86 | $mail->Subject = $app . ' crash log' . (!isEmpty($userEmail) ? ' from ' . clean($userEmail) : ''); 87 | 88 | $message = 'Processed on: ' . date("Y-m-d H:i:s") . "
\r\n" 89 | . 'App: ' . $app . "
\r\n" 90 | . 'Sender: ' . (!isEmpty($userEmail) ? clean($userEmail) : 'unknown') . "
\r\n
\r\n" 91 | . (!isEmpty($userProvidedDetails) ? "User-provided details:\r\n
" . $userProvidedDetails . "

\r\n" : ''); 92 | $mail->Body = $message; 93 | $mail->AltBody = $message; 94 | 95 | $mail->send(); 96 | } 97 | 98 | // Collect request data 99 | $crashlog = postString('crashlog'); 100 | $userProvidedDetails = clean(postString('userProvidedDetails')); 101 | $app = clean($_SERVER['HTTP_USER_AGENT']); 102 | 103 | /* 104 | // To test sending email from this script via `php index.php`, provide replacement data 105 | $crashlog = "test crash log content"; 106 | $app = "test app 2000"; 107 | */ 108 | 109 | if (isEmpty($crashlog) || isEmpty($app)) { 110 | header('X-PHP-Response-Code: 401', true, 401); 111 | die(); 112 | } 113 | 114 | $logIsJSON = $crashlog[0] == '{'; 115 | $filename = date("Y-m-d H.i.s") . ' ' . $app . ($logIsJSON ? '.ips' : '.crash'); 116 | $userEmail = postString('userEmail'); 117 | 118 | $tmpfile = tmpfile(); 119 | try { 120 | // Write report to file 121 | fwrite($tmpfile, $crashlog); 122 | fseek($tmpfile, 0); 123 | $path = stream_get_meta_data($tmpfile)['uri']; 124 | 125 | sendEmailForReportAsFilenameForSender($path, $filename, $app, $userProvidedDetails, $userEmail); 126 | } catch (Exception $e) { // PHPMailer exception 127 | header('X-PHP-Response-Code: 400', true, 400); 128 | echo($e->getMessage()); 129 | } catch (\Exception $e) { // Global PHP exception 130 | header('X-PHP-Response-Code: 400', true, 400); 131 | echo $e->getMessage(); 132 | } finally { 133 | fclose($tmpfile); 134 | } 135 | 136 | --------------------------------------------------------------------------------