Installation

Raygun crash reporting and error monitoring is available for iOStvOS & macOS with the raygun4apple provider. This provider can be used with both Objective-C and Swift applications.


Installation

1. Install the Raygun4Apple package

Download the latest package installer from here. Run the installer and follow the on-screen instructions.

Raygun4apple installation

2. Reference Raygun4Apple in your project

To use the framework in an app project, you will need to first select the Project in the Project Navigator. Then select the Target for the Project and scroll down to the Embedded Binaries section.

Raygun4apple installation

Next, in Finder, open the Library > Frameworks > raygun4apple directory. Open the folder corresponding to the platform your Target is currently supporting. Select the raygun4apple.framework file and drag it into the Embedded Binaries section.

3. Add the import dependency

For Swift projects you must create an Objective-C bridging header to be able to import the provider’s umbrella header file. You can find out how to do this by visiting Apple’s documentation for more details.

In your AppDelegate’s source file or Objective-C bridging header file, import the umbrella header for your target platform.

For iOS

#import <raygun4apple/raygun4apple_iOS.h>

For tvOS

#import <raygun4apple/raygun4apple_tvOS.h>

For macOS

#import <raygun4apple/raygun4apple_macOS.h>

4. Start the Raygun crash reporter

In your AppDelegate’s application function, add the following code to start the Raygun crash reporter. Your app API key is displayed when you create a new application in your Raygun account, or can be viewed in the application settings.

Objective-C:

RaygunClient *raygunClient = [RaygunClient sharedInstanceWithApiKey:@"YOUR_APP_API_KEY"];
[raygunClient enableCrashReporting];

Swift:

let raygunClient = RaygunClient.sharedInstance(apiKey: "YOUR_APP_API_KEY")
raygunClient.enableCrashReporting()

User tracking

This provider supports tracking the unique users who encounter errors and crashes in your mobile apps.

The identifier property on the RaygunUserInformation class is what separates one user from another. Be sure to set it with something unique, for example a database id, username or email address.

If the user changes, for instance when logging in or out, be sure to update the user information on the shared Raygun client each time. You can assign user information as described below.

Objective-C:

RaygunUserInformation *userInfo = [[RaygunUserInformation alloc] initWithIdentifier:@"user@raygun.com"
                                                                         withEmail:@"user@raygun.com"
                                                                      withFullName:@"Test User"
                                                                     withFirstName:@"Test"];
RaygunClient.sharedInstance.userInformation = userInfo;

Swift:

let userInformation = RaygunUserInformation(identifier: "user@raygun.com", email: "user@raygun.com", fullName: "Test User", firstName: "Test")
RaygunClient.sharedInstance().userInformation = userInformation