iOS tvOS
To monitor your mobile app with Dynatrace, you need to create an application in Dynatrace and set up OneAgent for your mobile app.
After that, you might also want to instrument your app's SwiftUI controls, fine-tune the auto-instrumentation features via configuration keys, or capture additional details via manual instrumentation.
To create a mobile application in Dynatrace
Use CocoaPods, Swift Package Manager, or Carthage to set up Real User Monitoring for your app. You can also follow the manual approach, though it's better to use one of the automated approaches.
You can set up OneAgent as a dynamic XCFramework, static XCFramework (available for OneAgent for iOS version 8.237+), traditional framework, or static library.
You can't combine the static Dynatrace XCFramework and the dynamic Session Replay XCFramework. For Session Replay, both XCFrameworks have to be dynamic.
If you use the static XCFramework, the traditional framework, or the static library to instrument your iOS app, you'll need to perform some additional steps.
Add Dynatrace OneAgent as a dependency within the CocoaPods Podfile
specification. You can do this by setting up OneAgent as a dynamic XCFramework, static XCFramework, traditional framework, or static library.
The traditional framework and the static library were deprecated as they don't support ARM64 Simulator architecture. This architecture is required to build apps on Mac computers with Apple silicon.
Add your application's identification keys to the Info.plist
file. Check the instrumentation wizard in Dynatrace for the exact values.
Trigger your project build once before using OneAgent SDK or any import declarations in Xcode.
CocoaPods automatically adds OneAgent to your iOS project during the build process.
For more information on Podfiles, see Podfile Syntax Reference.
https://github.com/Dynatrace/swift-mobile-sdk.git
as the package repository URL.Dynatrace
to add only OneAgentDynatraceSessionReplay
to add both OneAgent and the Session Replay on crashes module
Do not select DynatraceSessionReplay
for tvOS, as Session Replay is not available for this operating system.
Dynatrace-Static
to add only OneAgent as a static XCFramework-ObjC
linker flag to Other Linker Flags.You can skip this step if your application doesn't have Swift code or doesn't need access to the Dynatrace framework.
We assume that you already created the Objective-C bridging header file for your Swift code in Xcode.
#import <DynatraceStatic/Dynatrace.h>
-ObjC
linker flag to Other Linker Flags.You can skip this step if your application doesn't have Swift code or doesn't need access to the Dynatrace library.
We assume that you already created the Objective-C bridging header file for your Swift code in Xcode.
#import Dynatrace.h
Info.plist
file. Check the instrumentation wizard in Dynatrace for the exact values.To update the package version rule, double-click the product 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.
When switching from Carthage to Swift Package Manager, remove the script that you previously added in Xcode to remove iOS Simulator architecture from the release binary. Otherwise, you might have issues when building your project in Xcode 15+.
binary "https://mobileagent.downloads.dynatrace.com/ios/carthage/dynatrace.json" ~> 8.279
to your Cartfile
.carthage update --use-xcframeworks
.Dynatrace.framework
framework, run carthage update
.Dynatrace.xcframework
to add only OneAgentDynatrace.xcframework
and DynatraceSessionReplay.xcframework
to add both OneAgent and the Session Replay on crashes module
Do not add DynatraceSessionReplay.xcframework
for tvOS, as Session Replay is not available for this operating system.
-ObjC
linker flag to Other Linker Flags.libc++.tbd
library.You might need to add this library twice. In our internal tests, the library was linked to the project tree only after we added the library a second time.
You can skip this step if your application doesn't have Swift code or doesn't need access to the Dynatrace framework.
We assume that you already created the Objective-C bridging header file for your Swift code in Xcode.
#import <DynatraceStatic/Dynatrace.h>
In Xcode, add a Run Script phase as the last Build Phase of your application target.
Add the following script:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORKdoFRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"EXTRACTED_ARCHS=()for ARCH in $ARCHSdolipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")donelipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"rm "${EXTRACTED_ARCHS[@]}"rm "$FRAMEWORK_EXECUTABLE_PATH"mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"done
Select Run script: For install builds only.
This removes the iOS Simulator architecture from your release binary used for AppStore Connect upload.
-ObjC
linker flag to Other Linker Flags.You can skip this step if your application doesn't have Swift code or doesn't need access to the Dynatrace library.
We assume that you already created the Objective-C bridging header file for your Swift code in Xcode.
#import Dynatrace.h
Info.plist
file. Check the instrumentation wizard in Dynatrace for the exact values.Access the mobile instrumentation wizard.
Select iOS, and then go to the Developer tab.
Follow the provided instructions.
Add Dynatrace.xcframework
to have only OneAgent.
Add both Dynatrace.xcframework
and DynatraceSessionReplay.xcframework
to have both OneAgent and the Session Replay on crashes module.
Do not add DynatraceSessionReplay.xcframework
for tvOS, as Session Replay is not available for this operating system.
Perform some additional steps depending on the framework you use.
-ObjC
linker flag to Other Linker Flags.libc++.tbd
library.You might need to add this library twice. In our internal tests, the library was linked to the project tree only after we added the library a second time.
You can skip this step if your application doesn't have Swift code or doesn't need access to the Dynatrace framework.
We assume that you already created the Objective-C bridging header file for your Swift code in Xcode.
#import <DynatraceStatic/Dynatrace.h>
In Xcode, add a Run Script phase as the last Build Phase of your application target.
Add the following script:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORKdoFRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"EXTRACTED_ARCHS=()for ARCH in $ARCHSdolipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")donelipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"rm "${EXTRACTED_ARCHS[@]}"rm "$FRAMEWORK_EXECUTABLE_PATH"mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"done
Select Run script: For install builds only.
This removes the iOS Simulator architecture from your release binary used for AppStore Connect upload.
-ObjC
linker flag to Other Linker Flags.You can skip this step if your application doesn't have Swift code or doesn't need access to the Dynatrace library.
We assume that you already created the Objective-C bridging header file for your Swift code in Xcode.
#import Dynatrace.h
Trigger your project build once before using OneAgent SDK or any import declarations in Xcode.
The mobile instrumentation wizard in Dynatrace provides you with get-started instructions on instrumenting your iOS apps. To follow more detailed instructions, go to the Set up OneAgent section on this page.
The wizard also contains code snippets with your app's identification keys that you'll need to add to the Info.plist
file.
We don't recommend using several monitoring tools simultaneously with crash reporting or web request instrumentation functionality enabled. This might cause compatibility issues, reporting of wrong or invalid information, and loss of monitoring and crash data. Nevertheless, if you decide to do so, verify via manual testing that these tools are compatible.
To use both Dynatrace and Firebase, do one of the following.
Follow only one of the approaches above; don't perform both actions.
To use both Dynatrace and mPaaS, do one of the following.
Follow only one of the approaches above; don't perform both actions.
An auto-instrumented application can't carry out functions such as Dynatrace.shutdown()
or Dynatrace .flushEvents()
. You can manually insert these methods and other user-defined actions and events before performing auto-instrumentation.
The following controls can't be used to create autogenerated actions:
UIBarButton
items, including custom UIBarButton
items added to the navigation bar by a storyboard (such as info
) that use segues to transition to other views.