Dynatrace auto-instrumentation for iOS
Use the instructions provided here to instrument iOS and tvOS apps.
To set up user experience monitoring on your iOS apps, you can use CocoaPods, Swift Package Manager, or Carthage. You can also follow the manual approach, though we recommend that you use one of the automated approaches.
Independent of the selected approach, you must add the generated application and environment IDs to your project's
Info.plist file so that your iOS mobile app can send monitoring data to your Dynatrace monitoring environment.
Set up OneAgent with CocoaPods
In the Dynatrace menu, go to Mobile.
Select your mobile app.
On the app overview page, select Browse (…) > Edit.
From the app settings, select Instrumentation wizard > iOS.
Go to the CocoaPods tab, and add Dynatrace OneAgent as a dependency within the CocoaPods
Podfilespecification. You can do this by setting up OneAgent either as a dynamic framework or as a static library.
To set up Dynatrace as an XCFramework, add the
Dynatracepod to your
Podfile. Ensure that you uncomment the
# Uncomment this line to define a global platform for your project # platform :ios, '9.0' target 'DemoApp' do # Uncomment this line if you're using Swift or want to use dynamic frameworks use_frameworks! # Pods for DemoApp pod 'Dynatrace', '~> 8.227' end
To set up Dynatrace as a static library, add the
Dynatrace/libpod to your
Podfile. Ensure that you comment out the
# Uncomment this line to define a global platform for your project # platform :ios, '9.0' target 'DemoApp' do # Uncomment this line if you're using Swift or want to use dynamic frameworks # use_frameworks! # Pods for DemoApp pod 'Dynatrace/lib', '~> 8.227' end
CocoaPods automatically adds OneAgent to your iOS project during the build process.
For more information on Podfiles, see Podfile Syntax Reference.
Note that we deprecated the
Dynatrace.framework traditional fat framework and the
libDynatrace.a static library as they do not support arm64 Simulator architecture that is required for latest macOS computers used to build apps.
Set up OneAgent with Swift Package Manager
- In Xcode, select File > Swift Packages > Add Package Dependency.
https://github.com/Dynatrace/swift-mobile-sdk.gitas the package repository URL.
- Select either the
Dynatraceadds OneAgent for Mobile, which handles the automatic mobile app instrumentation.
DynatraceSessionReplayadds OneAgent for Mobile and the Session Replay on crashes module.
To update the package version rule, double-click the Dynatrace or DynatraceSessionReplay entry in the Swift Packages tab within the Xcode project settings. To change the product selection, remove the package and add it again.
To update the package, select File > Swift Packages > Update to Latest Package Versions in Xcode.
Note that you cannot edit Swift packages in Xcode 13.
Set up OneAgent with Carthage
binary "https://mobileagent.downloads.dynatrace.com/ios/carthage/dynatrace.json"to your
carthage update --use-xcframeworksor
carthage updatefor the deprecated traditional framework.
DynatraceSessionReplay.xcframeworkfrom the Carthage/Build folder to the Frameworks, Libraries and Embedded Content section located within the General tab of your Application Target, and set it to
Embed & Sign.
Set up OneAgent manually
- In the Dynatrace menu, go to Mobile.
- Select your mobile app.
- On the app overview page, select Browse (…) > Edit.
- From the app settings, select Instrumentation wizard > iOS.
- Go to the Developer tab, and follow the provided instructions.