Troubleshooting¶
SDK Initialization Validation¶
In the Debug environment, after you configure the TrueWatch SDK and run the application for the first time, check the debugger console in Xcode. The SDK uses assertions to check the correctness of several configurations and will crash and output related warnings when a configuration is incorrect.
For example: if the datakit metrics write address is not set when configuring the SDK, the program will crash and output a warning ⚠️ in the console.
*** Assertion failure in +[FTMobileAgent startWithConfigOptions:], FTMobileAgent.m:53
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Please set the datakit metrics write address'
Enabling Debug Mode¶
It is recommended to enable enableSDKDebugLog = YES in FTMobileConfig in the Debug environment and disable it in the Release environment. SDK debug logs use [FTLog] as the prefix identifier, and you can filter with [FTLog].
Note: When OS_ACTIVITY_MODE=disable is set in the scheme, SDK debug logs cannot be output normally. It is recommended to disable this setting during debugging.
It is recommended to disable Debug mode when releasing a Release version
Log Examples¶
Data Synchronization¶
//The following is a normal synchronization log
[FTLog][INFO] -[FTTrackDataManger flushWithEvents:type:] [line 143] ↵
Start reporting events (number of events reported this time: 2)
[FTLog][INFO] -[FTRequestLineBody getRequestBodyWithEventArray:] [line 149]
Upload Datas Type:RUM
Line RequestDatas:
...... datas ......
[FTLog][INFO] -[FTTrackDataManger flushWithEvents:type:]_block_invoke [line 157] ↵
Upload Response statusCode : 200
Before version 1.3.10, Upload Response statusCode : 200 is not printed. You can check whether the console has error logs. If there are no error logs, the upload was successful.
Error logs: Network failure: ...... or Server exception, please try again later ......
After version 1.5.16, you can search for [NETWORK] in the logs to view all data synchronization related logs.
Converting SDK Internal Logs to Cache Files¶
// Default paths: versions 1.4.11-1.4.12 /Library/Caches/FTLogs/FTLog xxxx-xx-xx--xx/xx/xx/xxx.log
// >= 1.4.13 /Documents/FTLogs/FTLog.log
// >= 1.4.11
[[FTLog sharedInstance] registerInnerLogCacheToLogsDirectory:nil fileNamePrefix:nil];
// >= 1.4.13
// Method 1: Default path
[[FTLog sharedInstance] registerInnerLogCacheToDefaultPath]
// Method 2: Specified path
NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject
stringByAppendingPathComponent:@"ExampleName.log"];
[[FTLog sharedInstance] registerInnerLogCacheToLogsFilePath:filePath];
To ensure the completeness of internal logs, this configuration needs to be set before SDK initialization
SDK Runs Normally But No Data¶
-
Troubleshoot DataKit to check whether it is running normally
-
Confirm that the SDK upload address
datakitUrlordatawayUrlis configured correctly and initialized properly. In debug mode, check the logs to determine whether the issue is with uploading -
Check whether DataKit is uploading data to the corresponding workspace and whether it is offline. You can confirm this by logging in to TrueWatch and checking Infrastructure.
Verifying Successful Data Collection¶
Logger¶
Set enableCustomLog = YES in FTLoggerConfig to enable collection and reporting of custom logs.
When the SDK collects logs, you can see SDK debug logs in the debugger console in Xcode.
[FTLog][INFO] -[FTRecordModel initWithSource:op:tags:fields:tm:] [line 36] write data = {
op = Logging;
opdata = {
fields = {
message = "xxxxx collected log content XXXXX";
source = "df_rum_ios_log";
tags = {
......
}
}
}
Seeing op = Logging; indicates that the Logger feature is enabled correctly and data is collected successfully.
RUM¶
When the SDK version is earlier than 1.4.14, Resource data and Action data (except launch action) are bound to the View. Make sure the View is collected before this data can be collected normally.
View collection: Set
enableTraceUserView = YESinFTRumConfigto enable automatic collection, or collect manually with-startViewWithName
View the SDK debug logs in the debugger console in Xcode.
[FTLog][INFO] -[FTRecordModel initWithSource:op:tags:fields:tm:] [line 36] write data = {
op = RUM;
opdata = {
fields = {
.......
};
source = action;
tags = {
........
}
}
}
Seeing op = RUM; indicates that the RUM feature is enabled correctly and data is collected successfully.
Trace¶
If enableLinkRumData = YES is set, you can see it displayed in RUM Resource data. View the SDK debug logs in the debugger console in Xcode.
[FTLog][INFO] -[FTRecordModel initWithSource:op:tags:fields:tm:] [line 36] write data = {
op = RUM;
opdata = {
fields = {
duration = 5873084;
"request_header" = "Accept:*/*\nx-datadog-parent-id:12914452039873665275\nx-datadog-trace-id:6849912365449426814\nx-datadog-origin:rum\nAccept-Language:en-US,en;q=0.9\nAccept-Encoding:gzip, deflate\nx-datadog-sampling-priority:2";
......
};
source = resource;
tags = {
......
"span_id" = 12914452039873665275;
"trace_id" = 6849912365449426814;
......
};
};
If you find data with op = RUM; and source = resource;, and its tags contain span_id and trace_id, it indicates that the Trace feature is enabled correctly.
Data Loss¶
Partial Data Loss¶
- If a Session data or Log in RUM, or a few Trace data entries, are missing
First, check the sampling configurations for RUM, Log, and Trace. For SDK 1.6.8+, it is recommended to use sessionSamplingRate, logSamplingRate, and traceSamplingRate, with values as percentages from 0 to 100, where 0 disables sampling and 100 samples everything. Positive numbers less than 1 are still valid fractional sampling rates; for example, 0.1 means 0.1%. Do not conclude that the feature is disabled just because the value is less than 1. Session sampling misses or logs/Trace not being selected proportionally can also cause partial data loss. The legacy attributes sampleRate / samplerate only support integer percentages and are deprecated; they may be removed in future versions. For the proportional units of legacy remote fields, see also Remote Configuration Fields.
- If Resource events or Action events (except launch action) in RUM are missing
Check whether automatic View collection is enabled or whether the Open API is used for manual collection. Resource events and Action events are bound to Views. Make sure the View is collected so these events can be collected normally.
- When the SDK version is <= 1.4.14, if some data is missing and you see debug logs like the following in the Xcode debugger console
Confirm that the NSDictionary parameters passed to the SDK meet the following requirements:
-
All dictionary keys are NSString
-
All objects are NSString, NSNumber, NSArray, NSDictionary, or NSNull
-
NSNumber is not NaN or infinity
It is recommended to use NSString for both keys and values.
- Troubleshoot network and load issues on the device uploading data and on the device where DataKit is installed.
Error Data Loss: Crash-Type Data¶
-
Check whether the Crash collection feature is enabled
-
Check whether SDK initialization completed before the Crash
-
Check whether other third-party components that capture crashes are used. If so, place FTMobileSDK initialization after that component
-
Check whether you are in the Xcode debugging stage
The SDK uses UNIX signals and Mach exceptions to capture crashes. Both capture methods are affected by Debug executable, which Xcode enables by default. It intercepts these exceptions before the SDK can capture them. Therefore, to capture crashes normally during debugging, manually disable Debug executable or test without attaching the debugger in Xcode.
Note: After disabling Debug executable, breakpoint debugging will no longer work.
Version Compatibility Issues¶
Missing Performance Metrics in RUM Resource Events¶
Affected versions: SDK version 1.3.10 and earlier
The SDK supports iOS 9 and above. Performance metrics in RUM Resource events require APIs supported on iOS 10 and above for collection, so if the user's device runs a system version below iOS 10, the collected Resource events will be missing the performance metrics part.
The carrier Attribute in RUM Error Data Displays --¶
On iOS 16.4 and above, CTCarrier in CoreTelephony is deprecated, and there is no replacement API. Using the deprecated API returns the static value --.
WebView¶
[xxViewController retain]: message sent to deallocated instance xxx¶
Affected versions: SDK version 1.4.10 and earlier
Cause: When using a WebView, you add an observer to the WebView, but the WebView does not remove the observer before the observer is about to be released. Because the SDK holds a strong reference to the WebView internally, the WebView is not released. When the observed KeyPath changes later, the observer is notified, but the observer has already been released, resulting in an EXC_BAD_ACCESS error.
Fix suggestions:
-
Upgrade the SDK version
-
Or remove the observer before it is about to be released.

