iOS SDK - Technical Guide
Overview
This document helps developers to set up and integrate Cardknox Payments SDK into Swift projects. The document contains steps for framework integration, required settings setup and import of SDK headers.
Technical Overview
The SDK is distributed as a
.framework.frameworkcontains theCardknoxPaymentsSDKbinary andObjectiveC.hheaders describing the SDK APIThe
CardknoxPaymentsSDKdoes not containbitcodeand cannot be integrated with applications that requirebitcode.frameworkonly supportsarm6464-bit architecture for device builds. Simulator targets are not supported.SDK minimum deployment target is 14.0
Framework File Integration
Obtain and place the downloaded
.frameworkfile to the root of your project (for example, alongside thexcodeprojfile):
Open the
Generalunder the applicationTarget. Find theFrameworks, Libraries, and Embedded Contentsection. Click on the+ iconfor adding a framework to the project.
+ iconopens the dialog screen for adding framework. On dialog click onAdd Otherdropbox, which opens a menu. On the menu click onAdd files....
Add files...opensChoose frameworks and libraries to adddialog. On dialog find the root folder of the project and selectCardknoxPaymentsSDK.frameworkfile.
After adding the framework, the
CardknoxPaymentsSDK.frameworkmust be inthe Frameworks, Libraries, and Embedded Contentsection. Pay attention to the value in theEmbedcolumn. The value must beEmbed & Sign.
Also after adding the framework, the
CardknoxPaymentsSDK.frameworkmust be inLink Binary With LibrariesandEmbed Frameworkssections.Link Binary With LibrariesandEmbed Frameworkssections are in theBuild Phasestab, under the applicationTarget.
SkiaSharp dependency
The goal is to reference the libSkiaSharp.framework. It can be found in the CardknoxPaymentsSDK.framework/Frameworks folder. Repeat the same steps for libSkiaSharp.framework integration.
Required Settings Setup
Disabling Bitcode
The Cardknox SDK doesn’t support bitcode. To disable Bitcode, follow these steps:
Click on your application target. Choose
Build Settings>AllSet the
Enable Bitcodeoption toNoin theBuild Optionssection
Info.plist merge
The
CardknoxPaymentsSDKframework contains anInfo.plistfile which contains various key/value pairs that are required by the framework, for example, it defines aNSBluetoothAlwaysUsageDescriptionkey with a value similar to “Bluetooth is required to find, connect to and transfer data between a card reader and the app"The application that is using the
CardknoxPaymentsSDKframework also defines anInfo.plistfile with its own key/value pairsThe goal is to merge the framework
Info.plistfile with the applicationInfo.plistin order to avoid runtime errors in theCardknoxPaymentsSDKframework code due to missing key/values.XCodedoesn't perform any merges automatically.Note that if there are identical keys present in the application
Info.plistand in the frameworkInfo.plistfiles, such as theNSBluetoothAlwaysUsageDescriptionkey; the value defined in the application Info.plist for that key will have priority during the merge; making it easy to override values in the frameworkInfo.plistTo merge the two files, define a
Run Scriptstep in theXCodeapplication Target'sBuild Phasessection and run thePlistBuddytool, as following:Add a new
Run Scriptstep toBuild Phases
Make sure that the
Run Scriptstep is the last step, below other steps (Compile Sources,Embed Frameworks, etc.). You can reposition steps by dragging up and down:
Expand the
Run Scriptstep
Delete the
Type a script...contents of the input box and add the following command/usr/libexec/PlistBuddy -c "merge CardknoxPaymentsSDK.framework/Info.plist" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
Globalization File
The SDK contains a file icudt.dat. This file is used by the dotnet runtime to configure globalization. Our SDK is using the en-US culture to format currency symbols, amount delimiters, etc.. This means the SDK is “culture sensitive” or “culture variant”.
dotnet runtime will look for the icudt.dat file in the “main bundle” which is the Swift app where the SDK is a guest. Therefor our goal is to copy the icudt.dat into the final application archive in XCode, whenever the app builds.
Define a new Run Script phase for your application Target in XCode
Input the following code:
CardknoxPaymentsSDK headers import
This section shows how to use the CardknoxPaymentsSDK in Swift code. For Swift applications, an umbrella header needs to be created and referenced by your application Target in order to properly embed the framework into your app. To create the umbrella header, follow the steps:
Create a new header file in the
Targetfolder viaFilemenu >New...>File from Template...ChooseHeader Fileoption; for example, the name might be:iOS.Swift.SampleApp-Bridging-Header.h
Clear all text in the header file
Add
#import "CardknoxPaymentsSDK/CardknoxPaymentsSDK.h"into the header file.
Navigate to your target’s
Build Settings>All.Find the
Objective-C Bridging Headeroption in theSwift Compiler - Generalsection, and set its value to be the relative path to the header file. For example, an application target namediOS.Swift.SampleAppwill haveiOS.Swift.SampleApp/iOS.Swift.SampleApp-Bridging-Header.hpath specified. The assumption here is that the header file is in theTargetfolder, alongside theInfo.plistfile.
Last updated
Was this helpful?

