Raygun crash reporting and error monitoring is available for iOS, tvOS & macOS with the raygun4apple provider. This provider can be used with both Objective-C and Swift applications.
1. Install the Raygun4Apple package
Download the latest package installer from here. Run the installer and follow the on-screen instructions.
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.
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.
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.
RaygunClient *raygunClient = [RaygunClient sharedInstanceWithApiKey:@"YOUR_APP_API_KEY"]; [raygunClient enableCrashReporting];
let raygunClient = RaygunClient.sharedInstance(apiKey: "YOUR_APP_API_KEY") raygunClient.enableCrashReporting()
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.
RaygunUserInformation *userInfo = [[RaygunUserInformation alloc] initWithIdentifier:@"firstname.lastname@example.org" withEmail:@"email@example.com" withFullName:@"Test User" withFirstName:@"Test"]; RaygunClient.sharedInstance.userInformation = userInfo;
let userInformation = RaygunUserInformation(identifier: "firstname.lastname@example.org", email: "email@example.com", fullName: "Test User", firstName: "Test") RaygunClient.sharedInstance().userInformation = userInformation