Page tree

Follow these steps to get your EUM App Key and instrument your iOS apps.

Get Your Application Key

After you completed the Getting Started Wizard, you were given an EUM App Key. You will need this key when you modify the source code. In some cases, multiple mobile applications can share the same key.

If you have completed the Getting Started Wizard, but don't have your EUM App Key, see Get Your Application Key.

Initialize the Agent 

Edit your app's AppDelegate.m file to initialize the Mobile Agent as soon as the app launches. This registers your application and only needs to be done once in your code.

  1. In the AppDelegate.m file, add this import statement:

    #import <ADEumInstrumentation/ADEumInstrumentation.h>
  2. In the method didFinishLaunchingWithOptions, create an ADEumAgentConfiguration object with the EUM App Key that you received when completing the Getting Started Wizard to initialize the iOS Agent:

    // Example EUM App Key: "AAA-AAB-AUM"
    ADEumAgentConfiguration *config = [[ADEumAgentConfiguration alloc] initWithAppKey:<#EUM_APP_KEY#>];

    Your code should look something like the following:

    #import <ADEumInstrumentation/ADEumInstrumentation.h>
    #import "AppDelegate.h"
     
        // ...
        -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
            // Example EUM App Key: "AAA-AAB-AUM"
            ADEumAgentConfiguration *config = [[ADEumAgentConfiguration alloc] initWithAppKey:<#EUM_APP_KEY#>]; 
            // other tasks
            return YES;
        }
    
  3. Configure the iOS Agent to report metrics and screenshots to the SaaS EUM Server in your region and initialize the agent by passing the ADEumAgentConfiguration object to the method initWithConfiguration. If you are using an on-premises EUM Server, see Configure the iOS Agent for On-Prem Deployments (Optional).

    #import <ADEumInstrumentation/ADEumInstrumentation.h>
    #import "AppDelegate.h"
     
        // ...
        -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
            ADEumAgentConfiguration *config = [[ADEumAgentConfiguration alloc] initWithAppKey:<#EUM_APP_KEY#>];
            //The default SaaS EUM Server and Screenshot Service are in the Americas, 
    		// so you can omit the following settings if you are in the Americas.
            config.collectorURL = @"https://<your_region>-col.eum-appdynamics.com";
            config.screenshotURL = @"https://<you_region>-image.eum-appdynamics.com/";
            [ADEumInstrumentation initWithConfiguration: config];
            // other tasks
            return YES;
         }
    
  4. (Optional) If your application is using another tool to report crashes, the iOS Agent may warn you with the following message:

    Agent has detected a third party crash reporting tool. You may wish to disable AppDynamics Crash Reporting by setting the crashReportingEnabled configuration flag to NO

    You are recommended to use only one crash reporting tool for better results. See Disable Crash Reporting for instructions on how to disable the iOS Agent's crash reporting.

  5. Save the file.

The iOS Agent is compatible with applications created using the Swift programming language.  

  1. In your application's AppDelegate class, add this import statement:

    import ADEumInstrumentation
  2. In the AppDelegate class didFinishLaunchingWithOptions, create an ADEumAgentConfiguration object with the EUM App Key that you received when completing the Getting Started Wizard to initialize the iOS Agent:

    #import <ADEumInstrumentation/ADEumInstrumentation.h>
    #import "AppDelegate.h"
     
        // ...
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            let config = ADEumAgentConfiguration(appKey: <#EUM_APP_KEY#>)
        }
  3. Configure the iOS Agent to report metrics and screenshots to the SaaS EUM Server in your region, and initialize the agent by passing the initWith() method that takes the ADEumAgentConfiguration object as a parameter.

    If you are using an on-premises EUM Server, see Configure the iOS Agent for On-Prem Deployments (Optional).

    #import <ADEumInstrumentation/ADEumInstrumentation.h>
    #import "AppDelegate.h"
     
        // ...
         func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            let config = ADEumAgentConfiguration(appKey: <#EUM_APP_KEY#>)
            config.collectorURL = "https://<your_region>.eum-appdynamics.com"
            config.screenshotURL = "https://<your_region>-image.eum-appdynamics.com"
            ADEumInstrumentation.initWith(config)
            // other tasks
            return true
        }
    // ...
  4. (Optional) If your application is using another tool to report crashes, the iOS Agent will warn you with the following message:

    Agent has detected a third party crash reporting tool. You may wish to disable AppDynamics Crash Reporting by setting the crashReportingEnabled configuration flag to NO

    We recommend you use only one crash reporting tool for better results. See Disable Crash Reporting for instructions on how to disable the iOS Agent's crash reporting.

  5. Save the file.

Apps written for watchOS 1 contain a WatchKit extension that runs on the user's iPhone, but watchOS 2 also supports a new architecture, where the WatchKit extension runs on the Apple Watch itself. Splunk AppDynamics supports the watchOS 1 architecture, but not the new watchOS 2 architecture. Note that apps using the watchOS 1 architecture can run on both watchOS 1 and 2, so if your application is designed for watchOS 1, you can use Splunk AppDynamics on both versions of watchOS.

Because watchOS 1 apps are functionally launched in response to an interaction with the Watch UI, the SDK initialization code should be called at the point of that interaction in the iPhone app, which is usually not at the extension's AppDelegate.m call. The syntax remains the same.

Generate a dSYM File

To enable the agent to provide human-readable information in the crash snapshots that are produced if the application crashes, compile with the DWARF with dSYM file option to generate a debug symbols (dSYM) file for the application. For more details about why you would want to do this, see Get Human-Readable Crash Snapshots.

  1. In Xcode, select your project in the Project Navigator.
  2. In the target list, select the target that builds your application.
  3. Select the Build Settings tab.
  4. In the Build Options section, make sure that the Debug Information Format is set to DWARF with dSYM File.
  5. Rebuild the Xcode project.

Monitor Crashes with the dSYM File 

This step is optional but highly recommended if you plan to monitor crashes. Splunk AppDynamics needs the dSYM file for the application to produce human-readable stack traces for crash snapshots. 

For instructions, see Upload the dSYM File.

Customize the Instrumentation (Optional)

 The ADEumInstrumentation class has additional methods to allow you to extend the kinds of data you can collect and aggregate using Splunk AppDynamics. There are five basic kinds of extensions that you can create:

  • Custom timers: any arbitrary sequence of events within your code timed, even spanning multiple methods
  • Custom metrics: any integer-based data you wish to collect
  • User data: any string key/value pair you think might be useful
  • Information points: how often a single method is invoked, and how long it takes to run
  • Breadcrumbs: context for a crash

See Customize the iOS Instrumentation.