Apply the License Key
If you haven't get a license key, please check out how to obtain a license key.
ComPDFKit PDF SDK currently supports two authentication methods to verify license keys: online authentication and offline authentication.
Learn about:
What is the authentication mechanism of ComPDFKit's license?
What are the differences between Online Authentication and Offline Authentication?
Copying the License Key
After getting the license key, follow the steps below to apply it to your project:
In the email you received, locate the
XML
file containing the license key.Simply drag the
XML
file into your project manually, as shown in the image below:
When the file options dialog appears, make sure to check "Copy items if needed" and "Create groups", as shown below:

Apply the License Key
Before using any ComPDFKit PDF SDK classes, you must perform the following steps to apply the license to your application:
- In
AppDelegate.swift
, import the header file ComPDFKit. - Use the online activation
XML
obtained in the previous step to initialize with the method below. - To initialize the license, you need to call it in
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
, as shown in the code below:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Set your online license key here. ComPDFKit is commercial software.
// Each ComPDFKit license is bound to a specific app bundle id.
// com.compdfkit.pdfviewe
guard let xmlFliePath = Bundle.main.path(forResource: "license_key_ios", ofType: "xml") else {
return true
}
CPDFKit.verify(withPath: xmlFliePath, completionHandler: { code, message in
print("Code: \(code), Message:\(String(describing: message))")
})
}
#import <ComPDFKit/ComPDFKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Set your online license key here. ComPDFKit is commercial software.
// Each ComPDFKit license is bound to a specific app bundle id.
// com.compdfkit.pdfviewer
NSString *xmlFileString = [[NSBundle mainBundle] pathForResource:@"license_key_ios" ofType:@"xml"];
[CPDFKit verifyWithPath:xmlFileString completionHandler:^(CPDFKitOnlineLicenseCode code, NSString *message) {
NSLog(@"Code: %ld, message: %@", (long)code, message);
}];
}
Compile and run the project. If the console outputs "version information", it means that the license has been set successfully. Otherwise, please check the "Troubleshooting" section at Troubleshooting or check error logs in the console to quickly identify and solve the issue.