- 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.
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 Cocoapods
- Importing mimik Components
- Initializing mimik Instance
- Activating Console Logging
Technical Prerequisites
This tutorial has the following technical prerequisite: A device running the latest iOS version.
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. |
---|
Using the mimik Client Library components in an iOS project
Using the mimik Client Library components in an iOS project is a three-phase process. The phases are:
- Configuring a Podfile
- Executing pod commands
- Code importing and initializing
The following sections describe the details of each phase.
Configuring a Podfile
The mimik Client Library components are dependencies that 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, as shown in Lines 2-3
. It also declares the mimik Client Library pod components at Lines 7-8
. With additional configuration requirements at Lines 11-18
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 'EdgeEngineDeveloper'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 Components
Executing pod commands
Once a Podfile
is configured, developers run a few commands, both from the terminal and from within code to get an application using mimik libraries up and running.
The sections that follow describe the details.
Installing mimik components using pod install
Once the dependencies are defined in a Podfile
, developers initiate the installation of EdgeCore
and EdgeEngineDeveloper
pods as well as their dependencies into the iOS project using the following command:
pod install
Running pod install
against the Podfile
as described above displays output similar to the following:
Analyzing dependenciesDownloading dependenciesInstalling AlamofireInstalling AppAuthInstalling EdgeCoreInstalling EdgeEngineDeveloperInstalling JWTDecodeInstalling SwiftyJSONGenerating Pods projectIntegrating client project
At this point, the mimik Client Library components are installed in the iOS project's workspace, ready to be imported in code.
Importing the mimik Components
Before developers can initialize the mimik Client Library components, they need to import the EdgeCore
and EdgeEngineDeveloper
component references into their code. The code example below shows you how to use the import
command inline in code to import mimik components.
import EdgeCoreimport EdgeEngine
Initializing the mimik Instance
Before developers can start taking advantage of the mimik Components API, they need to initialize a mimik Instance in a form of a EdgeClient
class. This enables both EdgeCore
and EdgeEngineDeveloper
API sets in the project. Listing 2 below shows an example of how to do this.
1: import EdgeCore2: import EdgeEngine3:4: let edgeClient: EdgeClient = {5: return EdgeClient()6: }()
Listing 2: The code for initializing the mimik Instance in an iOS application
Notice the code EdgeClient()
at Line 5.
This is where the instance of EdgeClient
class gets created.
With that, the mimik Client Library Core and Engine components have been initialized and are ready for use using this mimik Instance.
NOTE:
Full mimik Client Library API reference documentation is available here.
Activating Console Logging
Console logging is an important tool for developers when debugging software issues. The mimik Client Library provides a customizable console logging system that developers can configure to suit their needs. This amended mimik Instance initializer code example below in Listing 3 shows you how to activate a debug level console logging of the mimik Client Library.
1: let edgeClient: EdgeClient = {2: EdgeClient.setLoggingLevel(level: .debug, module: .edgeCore)3: EdgeClient.setLoggingLevel(level: .debug, module: .edgeEngine)4: return EdgeClient()5: }()
Listing 3: Setting up console logging using the mimik Client Library
NOTE: For additional information about the available console logging API see here. |
---|