Supplemental information
Find below essential supplemental information such as covering unit testing, thread safety, and dependency management.
Unit testing
It's easy to write unit tests for your app logic that uses the HERE SDK. Below you can see an example using XCTest.
func testAngle() throws {
// Static creation of angle object.
let angle = Angle.fromRadians(angle: 0.174533)
let angleInDegrees = angle.degrees
// Round the test angle to 1 significant decimal.
let roundedAngleInDegrees = round(angleInDegrees)
let expectedAngleInDegrees: Double = 10
XCTAssertEqual(roundedAngleInDegrees, expectedAngleInDegrees, "This is a message for a failed test.")
}It is not necessary to initialize the HERE SDK when writing unit tests.
Check the "UnitTesting" example app to find more use case examples.
Track HERE SDK Usage Statistics
The HERE SDK provides a way to monitor network usage using UsageStats. This class collects statistics on uploaded and downloaded data. Use sdkNativeEngine.getSdkUsageStats() and sdkNativeEngine.enableUsageStats() to retrieve network statistics. To reset the counters, use sdkNativeEngine.clearPersistentUsageStats() and sdkNativeEngine.clearUsageStatsCache(). To enable tracking, use the following:
SDKNativeEngine.sharedInstance?.enableUsageStats(enabled: true)Once enabled, the HERE SDK tracks network usage across different modules. To retrieve and log the tracked data, use the following method:
func logUsageStats() {
let currentUsageStats: [UsageStats] = SDKNativeEngine.sharedInstance!.sdkUsageStats
for usageStat in currentUsageStats {
print("UsageStats: Network Usage for feature: \(usageStat.feature)")
for currentNetworkUsage in usageStat.networkStats {
print("UsageStats: Bytes sent: \(currentNetworkUsage.sentBytes)")
print("UsageStats: Bytes received: \(currentNetworkUsage.receivedBytes)")
print("UsageStats: Network requests sent: \(currentNetworkUsage.requestCounter)")
print("UsageStats: For method: \(currentNetworkUsage.methodCall)")
}
}
}An example output may look like this for one used feature. In this case, rendering was used, which relates to the rendering map data layer :
Network Usage for feature: rendering
Bytes sent: 12843
Bytes received: 257590
Network requests sent: 10
For method MapContent%RENDERINGUsageStats contains a list of NetworkStats for each Feature, such as RENDERING or SEARCH. Each NetworkStats entry includes sentBytes, receivedBytes, requestCounter, and the corresponding methodCall used by the respective Feature. UsageStats is retained only for the current app session.
Note that calling enableUsageStats() is not persisted by the HERE SDK - same as for other settings: therefore, UsageStats should be enabled every time before the initialization of the HERE SDK - if they have been enabled before at runtime and if you want to continue to track the network statistics. Also, please note that the gathered data is only counting HERE SDK usages for the executed app on a device.
Thread safety
The HERE SDK is not guaranteed to be thread safe and it is required to make calls to the SDK from the main thread. Internally, the HERE SDK will offload most of its work to a background thread, but callbacks to your code will always occur on the main thread. In general, thread safety is the responsibility of the caller. For example, it is unsafe to reuse an engine on different threads unless your code is synchronized.
Dependency management
Currently, dependency management via CocoaPods is not yet supported. This means that the HERE SDK framework must be copied locally to an application project as described in the Get started section.
Use the HERE SDK with other frameworks
You can use the HERE SDK with other frameworks. For example, it is possible to combine an open street map with a SearchEngine, if you wish to do so.
-
Xamarin: The HERE SDK does not support Xamarin, but customers can implement a wrapper for Xamarin on top of the public APIs offered by the HERE SDK. We do no commit to make changes to the HERE SDK to support the related test tooling for Xamarin.
-
React Native: React Native is not supported. However, customers can implement a wrapper on their own, but we do not provide any support for such a task.
Updated 10 hours ago