TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Mar 2017 |
Maintained by David Cramer, Tommy Mikalsen, Armin Ronacher, Sentry.
Objective-c client for Sentry.
The easiest way is to use CocoaPods. It takes care of all required frameworks and third party dependencies:
pod 'Raven', :git => 'https://github.com/getsentry/raven-objc.git', :tag => '1.0.1'
Alternatively, you can install manually.
git clone git://github.com/getsentry/raven-objc
Raven
subfolder to your project. Check both "copy items into destination group's folder" and your target.Alternatively you can add this code as a Git submodule:
cd [your project root]
git submodule add git://github.com/getsentry/raven-objc
Raven
subfolder to your project. Uncheck the "copy items into destination group's folder" box, do check your target.While you are free to initialize as many instances of RavenClient
as is appropriate for your application, there is a shared singleton instance that is globally available. This singleton instance is often configured in your app delegate's application:didFinishLaunchingWithOptions:
method:
#import "RavenClient.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
RavenClient *client = [RavenClient clientWithDSN:@"[SENTRY_DSN]"];
// [...]
return YES;
}
If you would like to use the singleton pattern, you can set the shared client that is used with the
+[setSharedClient:]
class method. After setting a client, you can retreive the singleton instance via
the sharedClient
singleton method:
[RavenClient setSharedClient:client];
NSLog(@"I am your RavenClient singleton : %@", [RavenClient sharedClient]);
// Sending a basic message (note, does not include a stacktrace):
[[RavenClient sharedClient] captureMessage:@"TEST 1 2 3"];
// Sending a message with another level and a stacktrace:
[[RavenClient sharedClient] captureMessage:@"TEST 1 2 3" level:kRavenLogLevelDebugInfo method:__FUNCTION__ file:__FILE__ line:__LINE__];
// Recommended macro to send a message with automatic stacktrace:
RavenCaptureMessage(@"TEST %i %@ %f", 1, @"2", 3.0);
Setup a global exception handler:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
RavenClient *client = [RavenClient clientWithDSN:@"https://[public]:[secret]@[server]/[project id]"];
[client setupExceptionHandler];
// [...]
return YES;
}
Or, capture a single exception:
@try {
[self performSelector:@selector(nonExistingSelector)];
}
@catch (NSException *exception) {
RavenCaptureException(exception);
}
You can also capture errors:
NSError *error;
[[NSFileManager defaultManager] removeItemAtPath:@"some/path" error:&error];
RavenCaptureError(error);
Note: when using the global exception handler, exceptions will be sent the next time the app is started.
raven-objc requires ARC support and should run on iOS 5.0 and Mac OS X 10.7.
Have a bug? Please create an issue on GitHub!
https://github.com/getsentry/raven-objc/issues
raven-objc is an open source project and your contribution is very much appreciated.
raven-objc is available under the MIT license. See the LICENSE file for more info.