- Tutorials
- Integrating the mimik Client Library into an iOS project
Integrating the mimik Client Library into an iOS project
Objective
The objective of this document is to demonstrate the various concepts iOS software developers need to understand to integrate the mimik Client Library with an iOS application.
Intended Readers
The intended readers of this document are iOS software developers and system integrators using the mimik Client Library when developing an iOS application.
NOTE: The full mimik Client Library API reference documentation is available online, as well as in the XCode built-in documentation system. |
---|
What You'll Be Doing
In this article you'll be covering the following topics that are relevant to integrating the mimik Client Library into an iOS application:
- Configuring a Podfile
- Installing mimik Client Library cocoapods
- Importing mimik Client Library modules
- Initializing mimik Client Library
Prerequisites
- Connecting a real iOS device to the development computer and selecting it as the target in Xcode. This tutorial will not work with an iOS Simulator.
NOTE: Working with the iOS Simulator and the mimik Client Libraries entails some special consideration. For more more information about iOS Simulator support see this tutorial. |
---|
Configuring a Podfile
The mimik Client Library cocoapods get installed in an iOS project using the CocoaPods dependency manager. Listing 1 below shows an example of a CocoaPods's Podfile
that developers need to use with their iOS projects. The Podfile
defines the source code repository locations containing the relevant dependencies and it also declares the mimik Client Library pod components, with additional configuration requirements at the end.
1: platform :ios, '15.0'2: source 'https://github.com/CocoaPods/Specs.git'3: source 'https://github.com/mimikgit/cocoapod-edge-specs.git'4:5: target 'example' do6: use_frameworks!7: pod 'EdgeCore'8: pod 'mimOE-SE-iOS-developer'9: end10:11: post_install do |installer|12: installer.pods_project.targets.each do |target|13: target.build_configurations.each do |config|14: config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'15: config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'16: end17: end18: end
Listing 1: An example Podfile for working with mimik Client Library
Installing mimik Client Library cocoapods
Once the dependencies are defined in a Podfile
, developers initiate the installation of EdgeCore
and mimOE-SE-iOS-developer
cocoapods as well as their dependencies into the iOS project using the following command:
pod install --repo-update
Running pod install
against the Podfile
as described above displays output similar to the following:
Analyzing dependenciesDownloading dependenciesInstalling AlamofireInstalling AppAuthInstalling EdgeCoreInstalling mimOE-SE-iOS-developerInstalling JWTDecodeInstalling SwiftyJSONGenerating Pods projectIntegrating client project
At this point, the mimik Client Library is installed in the iOS project's workspace, and is ready to have its modules imported in the code.
Importing mimik Client Library modules
Before developers can initialize the mimik Client Library components, they need to import the EdgeCore
and EdgeEngine
modules references into their code. The code example below shows you how to use the import
command inline to do so.
import EdgeCoreimport EdgeEngine
Initializing mimik Client Library
Before developers can start taking advantage of the mimik Components interface, they need to initialize the mimik client library in a form of a EdgeClient class instance. These two import statements import both the EdgeCore
and EdgeEngine
modules into the project. Listing 2 below shows an example of how to do this.
1: import EdgeCore2: import EdgeEngine3:4: let edgeClient: EdgeClient = {5: EdgeClient.setLoggingLevel(level: .debug, module: .edgeCore)6: EdgeClient.setLoggingLevel(level: .debug, module: .edgeEngine)7: return EdgeClient()8: }()
Listing 2: The code for initializing the mimik Client Library in an iOS application
Notice the lien return EdgeClient()
. This is where the instance of EdgeClient class gets created.
setLoggingLevel
lines control the console logging output levels from the mimik CLient Library Components.
Ready
With that, the mimik Client Library has been initialized, its modules imported and its interface is ready to be used in the iOS project space.
NOTE: The full mimik Client Library API reference documentation is available online, as well as in the XCode built-in documentation system. |
---|
Additional reading
In order to get more out of this article, the reader could further familiarize themselves with the following concepts and techniques: