Coder Social home page Coder Social logo

mindscapehq / raygun4apple Goto Github PK

View Code? Open in Web Editor NEW
1.0 16.0 6.0 88.08 MB

Raygun4Apple provider supporting iOS, tvOS and macOS.

Home Page: https://raygun.com/

License: Other

Objective-C 33.75% C 47.09% C++ 18.84% Ruby 0.18% Swift 0.13%
raygun crash-reporting error-monitoring error-reporting error-handling exception-handling exception-reporting ios tvos macos

raygun4apple's Introduction

Raygun4Apple

Raygun provider for iOS, tvOS & macOS supporting Crash Reporting and Real User Monitoring.

Officially Supports:

  • iOS 12+
  • tvOS 12+
  • macOS 12+

Note: raygun4apple may work with earlier OS versions, however we recommend updating to the versions we build and test for to avoid experiencing any unexpected issues.

Installation

Using the Swift Package Manager

From Xcode

  1. Choose File > Add Package Dependencies…
  2. In the Search field on the top right, enter the Github URL for raygun4apple: https://github.com/MindscapeHQ/raygun4apple.git
  3. Click "Add Package", then choose your project under the "Add to Target" section. Click "Add Package" again.

A screenshot showing the installation of Raygun inside Xcode

You're now ready to configure the client.

OR: Manually

If you're not using Xcode to manage your packages, you can instead update your Package.swift file to include raygun4apple as a dependency.

Here is an example of a macOS CLI application which uses raygun4apple as a dependency:

import PackageDescription

let package = Package(
    name: "macos-cli",
    dependencies: [
        //Note - the version must be atleast 2.0.0 as this is earliest release of this package through SPM.
        .package(url: "https://github.com/MindscapeHQ/raygun4apple.git", from: "2.0.0"),
    ],
    targets: [
        .executableTarget(
            name: "macos-cli",
            dependencies: ["raygun4apple"])
    ]
)

With CocoaPods

To integrate Raygun using CocoaPods, update your Podfile to include:

pod 'raygun4apple'

Once updated, you can run pod install from Terminal.

With GitHub releases

The latest release can be found here. The frameworks are attached to each release as a zipped file. This can be downloaded, unzipped and included in you project directory.

Once included, go to your app's target General settings and add the raygun4apple framework to the Frameworks, Libraries, and Embedded Content section. Ensure that the framework is set to Embed & Sign.

Using Raygun

Swift

To use Raygun, import the package in your Swift file. Here is an example which imports raygun4apple, initializes the provider, and sends a test exception. Be sure to replace YOUR_API_KEY_HERE with your API key from your Application Settings screen in Raygun.

import raygun4apple

let raygunClient = RaygunClient.sharedInstance(apiKey: "YOUR_API_KEY_HERE")
raygunClient.enableCrashReporting()
raygunClient.send(exception: NSException.init(name: .genericException, reason: "This is an exception from Raygun4Apple!"))

NB: If you recieve a A server with the specified hostname could not be found error, you may need to enable outbound connections for your app. Choose your project target in the left-hand navigator, then choose the "Signing & Capabilities" tab, and check the Outgoing Connections (Client) in the "App Sandbox" section.

Swift UI

You might like to check our our Swift UI example app

You likely want to start Raygun in your AppDelegate. By default newer Swift UI apps do not come with an AppDelegate, so you can follow these instructions to add one to your project (for macOS you need to use NSApplication instead)

Once you've done that, your AppDelegate.swift should look something like this:

import Foundation
import UIKit
import raygun4apple


class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

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

      return true
    }
}

You are now tracking crashes across your application, and can report manually using the RaygunClient.sharedInstance(), for example:

RaygunClient.sharedInstance().send(exception: NSException.init(name: .genericException, reason: "This is an exception from Raygun4Apple!"))

Identifying customers

By default, each user will be identified as an anonymous user/customers. However you can set more detailed customer information with the following snippet.

RaygunClient.sharedInstance().userInformation = RaygunUserInformation.init(
    identifier: "123",
    email:      "[email protected]",
    fullName:   "Ronald Raygun",
    firstName:  "Ronald",
    anonymous:  false,
    uuid:       UUID().uuidString
)

(More initializers are provided on RaygunUserInformation should you want to omit some parts of this information)

Now your crashes will be tracked as affecting this user in Raygun Crash Reporting:

Screenshot showing affected users in the Raygun Crash Reporting Dashboard

Objective-C

In your AppDelegate class file, import the header for your target platform.

#import <raygun4apple/raygun4apple_iOS.h>

Initialize the Raygun client by adding the following snippet to your AppDelegate application:didFinishLaunchingWithOptions method:

[RaygunClient sharedInstanceWithApiKey:@"_INSERT_API_KEY_"];
[RaygunClient.sharedInstance enableCrashReporting];
[RaygunClient.sharedInstance enableRealUserMonitoring];
[RaygunClient.sharedInstance enableNetworkPerformanceMonitoring]; // Optional

Sending a test error event

To ensure that the Raygun client is correctly configured, try sending a test crash report with the following snippet.

[RaygunClient.sharedInstance sendException:@"Raygun has been successfully integrated!"
                                withReason:@"A test crash report from Raygun"
                                  withTags:@[@"Test"]
                            withCustomData:@{@"TestMessage":@"Hello World!"}];

Set up Customers

By default, each user will be identified as an anonymous user/customers. However you can set more detailed customer information with the following snippet.

RaygunUserInformation *userInfo = nil;
userInfo = [[RaygunUserInformation alloc] initWithIdentifier:@"[email protected]"
                                                   withEmail:@"[email protected]"
                                                withFullName:@"Ronald Raygun"
                                               withFirstName:@"Ronald"];
RaygunClient.sharedInstance.userInformation = userInfo;

Documentation

For more information please visit our public documentation here.

raygun4apple's People

Contributors

callum-mckay avatar mduncan26 avatar nikz avatar sumitramanga avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raygun4apple's Issues

Can't build project when installing via Cocoapods

Xcode produces this build error when I try to use raygun4apple version 1.4.0 installed via Cocoapods:

raygun4apple Group
Lexical or Preprocessor Issue Group
/Users/chase/company/repo/projects/mobile/ios/Pods/Flipper-Folly/folly/Demangle.h:19:10: 'folly/FBString.h' file not found
/Users/chase/company/repo/projects/mobile/ios/Pods/raygun4apple/Sources/KSCrash/Recording/Tools/KSDemangle_Swift.cpp:28:10: In file included from /Users/chase/company/repo/projects/mobile/ios/Pods/raygun4apple/Sources/KSCrash/Recording/Tools/KSDemangle_Swift.cpp:28:

the referenced line 28 is #include "Demangle.h"

My project is a React Native version 0.62.2 app.

The same happens whether my Podfile contains pod raygun4apple or pod 'raygun4apple', :git => 'https://github.com/MindscapeHQ/raygun4apple.git', :tag => '1.4.0'

visionOS support

Are there any plans to support visionOS? Currently, packages that depend on raygun4Apple cannot compile.

Exception EXC_BAD_ACCESS crash on iOS

I've been intermittently but consistently seeing an EXC_BAD_ACCESS "Attempted to dereference garbage pointer crash" on our iOS app that uses Raygun for crash reporting. The call stack suggests it's coming from the raygun4apple library itself. I'm currently using version 1.4.0 of the library, but have records of the crash back to version 1.3.8 too. Searching around the only related things I've found are this pull request and this forum post, which looks similar but not quite the same. The call stack I get always looks like this:

0   libsystem_pthread.dylib             0x1b04f8b38 0x1b04ed000 + 47928
1   libdispatch.dylib                   0x1b045cbf8 0x1b044c000 + 68600
2   libdispatch.dylib                   0x1b045c438 0x1b044c000 + 66616
3   libdispatch.dylib                   0x1b044f5ec 0x1b044c000 + 13804
4   libdispatch.dylib                   0x1b044fe98 0x1b044c000 + 16024
5   libdispatch.dylib                   0x1b04a7524 0x1b044c000 + 374052
6   libdispatch.dylib                   0x1b0459c8c 0x1b044c000 + 56460
7   Foundation                          0x1b0baa6c0 0x1b0a95000 + 1136320
8   Foundation                          0x1b0baabf4 0x1b0a95000 + 1137652
9   Foundation                          0x1b0ab2fc4 0x1b0a95000 + 122820
10  Foundation                          0x1b0baa1fc 0x1b0a95000 + 1135100
11  Foundation                          0x1b0ab32c0 0x1b0a95000 + 123584
12  Foundation                          0x1b0ba7fa0 0x1b0a95000 + 1126304
13  CFNetwork                           0x1b3a53eb4 0x1b3a1d000 + 224948
14  CFNetwork                           0x1b3a4349c 0x1b3a1d000 + 156828
15  raygun4apple                        0x104d87b54 _hidden#1941_ (__hidden#1986_:316)
16  raygun4apple                        0x104d5b9fc _hidden#1124_ (__hidden#1128_:0)
17  raygun4apple                        0x104d5b920 _hidden#1123_ (__hidden#1128_:55)
18  libobjc.A.dylib                     0x1b051e978 0x1b04fe000 + 133496

I can attach the downloaded raw data from the Raygun report as well.
raw data.zip

Error when emnbdding Raygun framework

Hi there,

When I embed & sign in Raygun framework I get:

Showing All Messages
Multiple commands produce '/Users/daniyaldehleh/Library/Developer/Xcode/DerivedData/BeTimefulSafari3-cryuivktttyogyejpndbamqtifqq/Build/Products/Debug/BeTimeful.app/Contents/Frameworks/raygun4apple.framework':
1) Target 'BeTimeful' has copy command from '/Users/daniyaldehleh/Library/Developer/Xcode/DerivedData/BeTimefulSafari3-cryuivktttyogyejpndbamqtifqq/Build/Products/Debug/raygun4apple.framework' to '/Users/daniyaldehleh/Library/Developer/Xcode/DerivedData/BeTimefulSafari3-cryuivktttyogyejpndbamqtifqq/Build/Products/Debug/BeTimeful.app/Contents/Frameworks/raygun4apple.framework'
2) That command depends on command in Target 'BeTimeful': script phase “[CP] Embed Pods Frameworks”

what shall i do?

Xcode 16.0 beta build fail

Hi,

I am currently testing the Xcode 16.0 beta version but it fails to build my app which uses the raygun4apple package in version 2.0.1

I have the following error messages :

Screenshot 2024-06-18 at 16 06 11
Screenshot 2024-06-18 at 16 06 27
Screenshot 2024-06-18 at 16 06 35

The app builds great if I remove the package dependency.

I haven't seen any issue about it yet so I am asking it.

Could you help me ?

Regards,

Alexandre

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.