SquareSquash / cocoa

Squash iOS and Mac OS X client library
Apache License 2.0
4 stars 4 forks source link

Squash Client Library: Cocoa/Objective-C (iOS & Mac OS X)

This client library reports exceptions to Squash, the Squarish exception reporting and management system.

Documentation

Comprehensive documentation is written in YARD- and Markdown-formatted comments throughout the source. To view this documentation as an HTML site, run Doxygen with doxygen Doxyfile. Doxygen and Graphviz must be installed.

For an overview of the various components of Squash, see the website documentation at https://github.com/SquareSquash/web.

Compatibility

This library is compatible with projects targeting iOS version 5.0 and above, or Mac OS X 10.5 and above, and written using Objective-C 2.0 or above.

Requirements

This library uses PLCrashReporter (by Landon Fuller), Apple's Reachability library, and Peter Hosey's ISO8601DateFormatter library. The latter two are compiled directly into the library. The former is included as a sub-project and compiled as part of the build process. For iOS, the libCrashReporter static library is created alongside the libSquashCocoa static library. For Mac OS X, the CrashReporter framework is embedded inside the SquashCocoa framework.

Usage

iOS

Compile the code with the correct scheme and architecture, creating a libSquashCocoa iOS.a library. Add this library to your project, being sure it is included in your project's Link Binary With Libraries build phase.

You may also need to link against libstdc++ to avoid linker errors.. No idea why.

Mac OS X

Compile the code with the correct scheme and architecture, creating a SquashCocoa OSX.framework framework. Add this framework to your project, being sure that it is included in your project's Link Binary with Libraries build phase.

Both Platforms

Add the SquashCocoa.h header file to your project and import it:

#import "SquashCocoa.h"

Add the following code somewhere in your application that gets invoked on startup, such as your app delegate's application:didFinishLaunchingWithOptions: method:

[SquashCocoa sharedClient].APIKey = @"YOUR_API_KEY";
[SquashCocoa sharedClient].environment = @"production";
[SquashCocoa sharedClient].host = @"https://your.squash.host";
[SquashCocoa sharedClient].revision = @"GIT_REVISION_OF_RELEASED_PRODUCT";
[[SquashCocoa sharedClient] reportErrors];
[[SquashCocoa sharedClient] hook];

The reportErrors method loads any errors recorded from previous crashes and transmits them to Squash. Errors are only removed from this queue when Squash successfully receives them.

the hook method adds the uncaught-exception and default signal handlers that allow Squash to record new crashes.

Configuration

You can configure the client using the properties of the [SquashCocoa sharedClient] singleton instance. The following properties are available:

General

Error Transmission

Exception Filtering

Error Transmission

Exceptions are transmitted to Squash using JSON-over-HTTPS. A default API endpoint is pre-configured, though you can always set your own (see Configuration above).

The Example "Tester" Targets

Both the iOS and OS X sub-projects each have a target that compiles a simple application from which you can raise a signal or an exception. You can use this to test your Squash integration, or as a template to integrating Squash into your own project.

The easiest way to use the "tester" targets is to run the Squash web server locally on port 3000, and alter the Build configuration variable SQUASH_API_KEY to the API key of a project you create in your local web server. That should be all you need; both products should begin uploading deploy notifications, symbolications, and exception notifications. Remember that exception notifications are not uploaded until the app is re-launched following a crash.

If you want to use the tester target as a guide to integrating Squash into your own projects, there are a few things you should be aware of:

Sub-Licenses

PLCrashReporter by Landon Fuller is distributed under the MIT license. See the LICENSE file under the project directory for more information.

ISO8601DateFormatter by Peter Hosey is distributed under the MIT license. See the LICENSE.txt file under the project directory for more information.

Reachability by Apple, Inc. is distributed under Apple's open-source license. See the Reachability.h file for more information.