- Notifications
You must be signed in to change notification settings - Fork2
Show how to use the third-party Swift Package Manager to integrate the ComPDFKit PDF SDK for Swift into iOS applications.
ComPDFKit/compdfkit-pdf-sdk-apple-package
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
ComPDFKit PDF SDK seamlessly operates onWeb,Windows,Android,iOS,Mac, andServer, with support for cross-platform frameworks such asReact Native,Flutter, etc.
ComPDFKit PDF SDK - Apple Package is a configuration file tailored for seamless integration of our Swift-based PDF Library into iOS applications.ComPDFKit PDF SDK - Swift provides a slick out-of-the-box responsive UI that interacts with the core library to view, annotate, and manipulate PDFs. It is feature-rich and battle-tested, making PDF files process much easier and faster for iOS and macOS devices.
- ComPDFKit PDF Library for iOS (Objective-C)
- ComPDFKit PDF Library for Android
- ComPDFKit PDF SDK -Flutter Library
- ComPDFKit PDF SDK -React Native Library
- How to Build an iOS PDF Viewer or Editor in Swift
- How to Build an iOS PDF Viewer or Editor in Objective-C
It's easy to embed ComPDFKit into an iOS application with a few lines of Swift or Objective-C code. Take a few minutes to get started.
The following sections explain how to run integration with Swift Package into your project
ComPDFKit PDF SDK - Swift Package requires the latest stable version of Xcode available at the time the release was made. This is a hard requirement, as each version of Xcode is bundled with a specific version of the iOS Base SDK, which often defines how UIKit and various other frameworks behave.
- The iOS 10.0 or higher.
- TheXcode 13.0 or newer for Objective-C or Swift.
ComPDFKit Apple Package supports flexible licensing options, including online and offline licenses. You can apply for afree trial license on our website or contactour sales team to get the offline license. Each license is only valid for a root domain name and any of its subdomains. However, any documents, sample code, or source code distribution from the released package of ComPDFKit PDF SDK to any third party is prohibited.
To learn how tocopy and apply the license key and more details about our license, please visit our comprehensive documentation.
Open Xcode and selectFile >New >Project… to create a new project for your application:

Choose theApp template for your project:

When prompted, enter your app name (ComPDFKit-Demo) and your organization identifier (com.example) and chooseStoryboard for the interface:

ClickNext and select the location to save the project.
ClickCreate to finish.
Open your application in Xcode and select your project’sPackage Dependencies tab.

Copy theComPDFKit Apple package repository URL into the search field:
https://github.com/ComPDFKit/compdfkit-pdf-sdk-apple-package

In theDependency Rule fields, selectBranch >master, and then clickAdd Package.
After the package download completes, selectAdd Package.
ComPDFKit should now be listed under Swift Package Dependencies in the Xcode Project navigator.
So far, we have added"ComPDFKit.xcframework" to the"PDFViewer" project, and finished the initialization of the ComPDFKit PDF SDK. Now, let’s start building a simple PDF viewer with just a few lines of code.
Prepare a test PDF file, drag and drop it into the newly createdPDFView project. By this way, you can load and preview the local PDF document using
NSBundle. The following image shows an example of importing a PDF document namedOnline5into the project.
Create a
CPDFDocumentobject throughNSURL, and create aCPDFViewto display it. The following code shows how to load PDF data using a local PDF path and display it byCPDFView.guardlet filePath=Bundle.main.path(forResource:"Online5", ofType:"pdf")else{return}leturl=URL(fileURLWithPath: filePath)letdocument=CPDFDocument(url: url)letrect=self.view.boundsletpdfView=CPDFView(frame:self.view.bounds)pdfView.autoresizingMask=[.flexibleWidth,.flexibleHeight]pdfView.document= document
Add the created
CPDFViewto the view of the current controller. The sample code shows below.self.view.addSubview(pdfView)
The code shown here is a collection of the steps mentioned above:
overridefunc viewWillAppear(_ animated:Bool){ super.viewWillAppear(animated)guardlet filePath=Bundle.main.path(forResource:"Online5", ofType:"pdf")else{return}leturl=URL(fileURLWithPath: filePath)letdocument=CPDFDocument(url: url)letrect=self.view.boundsletpdfView=CPDFView(frame:self.view.bounds) pdfView.autoresizingMask=[.flexibleWidth,.flexibleHeight] pdfView.document= documentself.view.addSubview(pdfView)}
Connect your device or simulator, and use shortcutCommand_R to run the App. The PDF file will be opened and displayed.

To protect user privacy, before accessing the sensitive privacy data, you need to find the "Info" configuration in your iOS 10.0 or higher iOS project and configure the relevant privacy terms as shown in the following picture.
<key>NSCameraUsageDescription</key><string>Your consent is required before you could access the function.</string><key>NSMicrophoneUsageDescription</key><string>Your consent is required before you could access the function.</string><key>NSPhotoLibraryAddUsageDescription</key><string>Your consent is required before you could access the function.</string><key>NSPhotoLibraryUsageDescription</key><string>Your consent is required before you could access the function.</string>
ComPDFKit has a professional R&D team that produces comprehensive technical documentation and guides to help developers. Also, you can get an immediate response when reporting your problems to our support team.
- For detailed information, please visit ourGuides page.
- Stay updated with the latest improvements through ourChangelog.
- For technical assistance, please reach out to ourTechnical Support.
- To get more details and an accurate quote, please contact ourSales Team.
Thanks,The ComPDFKit Team
About
Show how to use the third-party Swift Package Manager to integrate the ComPDFKit PDF SDK for Swift into iOS applications.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors2
Uh oh!
There was an error while loading.Please reload this page.

