Fork me on GitHub

BugSense in iOS

http://www.bugsense.com/docs/ios

Using BugSense in your iOS application is super easy!

  1. Download the BugSense-iOS [rev4.4].zip file, and unzip it.
  2. In Xcode, select the target that you want to use and, in the "Build Phases" tab expand the "Link Binary With Libraries" section. Press the "+" button, and then press "Add Other...". In the dialog box that appears, go to the framework's location and select it.
  3. The framework will appear at the top of the "Link Binary With Libraries" section and will also be added to your project files (left-hand pane).
  4. If your development stack is older than Xcode 4.2/iOS 5.0, BugSense may not work for you. We are working to improve compatibility with older development environments.

Configuring your project

BugSense depends on SystemConfiguration.framework, and you have to add it to your project by selecting it from the list of frameworks in "Link Binary With Libraries". Then, in your target properties:

  • change the value of "Strip Debug Symbols During Copy" and "Strip Linked Product" to No for all configurations (typically Debug and Release).
  • Make sure that "Deployment Post Processing" is set to No for all configurations.
  • Make sure that "Generate Debug Symbols" is similarly set to Yes.

Note: Your project should be working fine with those settings. However, if you find that reporting or symbolication is problematic, try this: * In your target's properties, * in "Other Linker Flags" add -ObjC * additionally, in "Other Linker Flags" add -all_load

Using BugSense

Add the following lines in the implementation file for your app delegate (something likeAppDelegate.m), ideally at the top ofapplication:didFinishLaunchingWithOptions: : 

#import <BugSense-iOS/BugSenseCrashController.h>
 
// ...
 
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //...
    NSDictionary *myStuff = [NSDictionary dictionaryWithObjectsAndKeys:@"myObject", @"myKey", nil];
    [BugSenseCrashController sharedInstanceWithBugSenseAPIKey:@"<Your BugSense API Key>"
                                                                             userDictionary:myStuff
                                                                             sendImmediately:NO];
    //...
}

The first argument is the BugSense API key (NSString). The second argument is anNSDictionary where you can put any object/key pairs to send back with the crash report. The third argument is a switch (BOOL) that can enable the dispatch of a crash report immediately after the crash has occurred, instead of on relaunch.

 

To see your crashes being reported, use your app on their own (on your device or on the simulator) and not through Xcode.

Exception logging

Logging exceptions is very simple: use the BUGSENSE_LOG macro to post the exception and its stacktrace along with a tag to identify it, e.g.:

@try {
    // some exception throwing code
} @catch (NSException *exc) {
    BUGSENSE_LOG(exc, @"Tag");
}

 

Read the full guide at Github

posted on 2012-05-21 12:26  pengyingh  阅读(200)  评论(0编辑  收藏  举报

导航