iOS
This section describes how to integrate DriveKit into an iOS mobile application.

Requirements

DriveKit is developed with the Swift 5 language and is compatible with iOS 10.0 and later versions.

Integration

DriveKit SDK is available on Cocoapods master repo.
To access the framework in the repository, add the following lines to your Podfile:
Podfile
1
target 'my-target' do
2
pod 'DriveKitCore'
3
end
Copied!

Initialization

DriveKit initialization

To initialize DriveKit in your app, you must call the initialization method in didFinishLaunchingWithOptions method of your application class.
AppDelegate.swift
1
import DriveKitCoreModule
2
3
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
4
DriveKit.shared.initialize()
5
...
6
}
Copied!
All DriveKit modules have a method initialize that must be called in didFinishLaunchingWithOptions method of your AppDelegate file.

Add API key

To use DriveKit framework, you have to obtain an API Key from DriveQuant. If you don't have an API key, please contact DriveQuant.
Once your API key is securely stored in your application, you can configure DriveKit by calling the following method:
1
DriveKit.shared.setApiKey(key: "MyApiKey")
Copied!

Identify user

Each driver must be identified with a unique identifier. Once you have this identifier, configure DriveKit by calling the following method:
1
DriveKit.shared.registerUser(userId: "MyUserId")
Copied!
You can call these 2 configuration methods anywhere in your app code. DriveKit will save the value locally. If the app is killed and relaunched, DriveKit will be reconfigured automatically.
DriveKit SDK will not work until you set the API key and the userId.

Check your configuration

You can check if DriveKit SDK is well configured with the following method:
1
DriveKit.shared.isConfigured()
Copied!
This method returns true if it is well configured.

Reset

If you need to reset DriveKit configuration (user logout for example), you can call the following method:
1
DriveKit.shared.reset()
Copied!
All data saved locally by DriveKit will be erased.
All DriverKit frameworks have reset method that erases all data saved locally by the framework.
Make sure that you call reset method of all frameworks to fully reset DriveKit configuration.

Logging

DriveKit comes with a logging feature that is enabled by default. This feature allows you to quickly identify the cause of a problem. We recommend leaving the log enabled as it does not consume memory space and is useful in the support phase. However, if you don't want to use it, it can be disabled.
Log will be written in app directory. One log file per month will be written with the name log-<YEAR>-<MONTH>.txt (example: log-2019-8.txt). All DriveKit modules log in this file. You can get a zip file with the log files of the previous month and the current one with the method DriveKitLog.shared.getZippedLogFilesUrl(), or by clicking on “Contact support” and changing the email receiver. The file will be in attachment of the email.
You can also make files of your application (including DriveKit log files) available in the iOS Files app by adding these 2 keys to your project's Info.plist file: UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace, setting them both to true.
To write log files on user smartphone, you must add the following entry in your info.plist file UIFileSharingEnabledandLSSupportsOpeningDocumentsInPlace set to true.
Disable logging by calling:
1
DriveKit.shared.disableLogging()
Copied!
To activate logging, call the following method:
1
DriveKit.shared.enableLogging()
Copied!

Xcode 12 Updates

After the deployment of iOS 14 and the new development tool Xcode 12, the distribution format of the DriveKit SDK has changed. We now use the XCFramework distribution format recommended by Apple.
This change requires some modifications to integrate version 1.6.3 of the DriveKit SDK and later versions.
  • The module names had to be modified to not match the name of a class present in the module. Pod names have not been modified.
  • Pods must be installed with Cocoapods version 1.10.0 because this version fixes a bug in the support of the XCFramework format needed for the DriveKit SDK to work properly. A release candidate is available and can be installed with the following command: sudo gem install cocoapods --pre
Changing module names requires the update of all DriveKit imports in the source code of your application. To simplify this operation, we invite you to use the migration script available here.
Just retrieve this script, drop it at the root of your Xcode project, where your Podfile is located, and run it. Thus, DriveKit imports of your different source files (Swift, ObjC) will be updated automatically.
Once these modifications have been made, the DriveKit SDK will be fully operational.
Last modified 7d ago