{ "html": "
\n

Installation

\n

The SDK can be installed using CocoaPods or Carthage.\nThis is the recommended client for both Swift and Objective-C.

\n

We recommend installing Sentry with CocoaPods.

\n

To integrate Sentry into your Xcode project using CocoaPods, specify\nit in your Podfile:

\n
source 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\nuse_frameworks!\n\ntarget 'YourApp' do\n    pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '3.9.1'\nend\n
\n
\n

If you want to use Sentry without KSCrash you can just remove it from the subspecs.\nKeep in mind that if you are not using KSCrash no events will be reported whenever you app crashes.\nAlso some function might do nothing if they are related to KSCrash.

\n

Afterwards run pod install. In case you encounter problems with\ndependencies and you are on a newer CocoaPods you might have to run\npod repo update first.

\n

To integrate Sentry into your Xcode project using Carthage, specify\nit in your Cartfile:

\n
github "getsentry/sentry-cocoa" "3.9.1"\n
\n
\n

Run carthage update to download the framework and drag the built\nSentry.framework into your Xcode project.

\n

Note that for Carthage we had to bundle KSCrash into the Sentry.framework to make everything work. So you will always get KSCrash with Sentry when using Carthage.

\n

We also provide a prebuilt version for every release which can be downloaded at releases on github.

\n
\n\n\n
\n

Configuration

\n

To use the client, change your AppDelegate’s application method to\ninstantiate the Sentry client:

\n
import Sentry\n\nfunc application(application: UIApplication,\n    didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {\n\n    // Create a Sentry client and start crash handler\n    do {\n        Client.shared = try Client(dsn: "___DSN___")\n        try Client.shared?.startCrashHandler()\n    } catch let error {\n        print("\\(error)")\n        // Wrong DSN or KSCrash not installed\n    }\n\n    return true\n}\n
\n
\n

If you prefer to use Objective-C you can do so like this:

\n
@import Sentry;\n\nNSError *error = nil;\nSentryClient *client = [[SentryClient alloc] initWithDsn:@"___DSN___" didFailWithError:&error];\nSentryClient.sharedClient = client;\n[SentryClient.sharedClient startCrashHandlerWithError:&error];\nif (nil != error) {\n    NSLog(@"%@", error);\n}\n
\n
\n

Note that if you call startCrashHandler will only catch errors if KSCrash is present.

\n
\n\n\n
\n

Debug Symbols

\n

Before you can start capturing crashes you will need to tell Sentry about the debug\ninformation by uploading dSYM files. Depending on your setup this can be\ndone in different ways:

\n\n
\n\n\n
\n

Upload Symbols with sentry-cli

\n

Your project’s dSYM can be upload during the build phase as a “Run\nScript”. For this you need to st the DEBUG_INFORMATION_FORMAT to be\nDWARF with dSYM File. By default, an Xcode project will only have\nDEBUG_INFORMATION_FORMAT set to DWARF with dSYM File in Release so\nmake sure everything is set in your build settings properly.

\n

You need to have an Auth Token for this to work. You can create an\nAuth Token here.

\n
    \n
  1. You will need to copy the below into a new Run Script and set your\nAUTH_TOKEN, ORG_SLUG, and PROJECT_SLUG
  2. \n
  3. Download and install sentry-cli\n\u2014 The best place to put this is in the /usr/local/bin/ directory
  4. \n
\n

Shell: /bin/bash

\n
if which sentry-cli >/dev/null; then\nexport SENTRY_ORG=___ORG_NAME___\nexport SENTRY_PROJECT=___PROJECT_NAME___\nexport SENTRY_AUTH_TOKEN=YOUR_AUTH_TOKEN\nERROR=$(sentry-cli upload-dsym 2>&1 >/dev/null)\nif [ ! $? -eq 0 ]; then\necho "warning: sentry-cli - $ERROR"\nfi\nelse\necho "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases"\nfi\n
\n
\n

The upload-dsym command automatically picks up the\nDWARF_DSYM_FOLDER_PATH environment variable that Xcode exports and\nlook for dSYM files there.

\n
\n

On Prem

\n

By default sentry-cli will connect to sentry.io. For\non-prem you need to export the SENTRY_URL environment variable\nto instruct the tool to connect to your server:

\n
export SENTRY_URL=https://mysentry.invalid/\n
\n
\n
\n
\n", "link": "https://docs.getsentry.com/platforms/ios/", "id": "apple-ios", "name": "iOS" }