{"id":19756867,"url":"https://github.com/compdfkit/compdfkit-pdf-sdk-apple-package","last_synced_at":"2025-08-02T23:07:42.810Z","repository":{"id":232183423,"uuid":"783670035","full_name":"ComPDFKit/compdfkit-pdf-sdk-apple-package","owner":"ComPDFKit","description":"Show how to use the third-party Swift Package Manager to integrate the ComPDFKit PDF SDK for Swift into iOS applications.","archived":false,"fork":false,"pushed_at":"2025-05-21T07:36:36.000Z","size":5801,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-21T08:30:45.442Z","etag":null,"topics":["compdfkit","ios","macos","pdf","pdf-editor","pdf-viewer","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":"https://www.compdf.com/ios","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ComPDFKit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-08T10:47:34.000Z","updated_at":"2025-05-21T07:36:22.000Z","dependencies_parsed_at":"2024-04-18T03:29:19.664Z","dependency_job_id":"068abaf9-4232-46ea-8db1-5b34d5a37eb2","html_url":"https://github.com/ComPDFKit/compdfkit-pdf-sdk-apple-package","commit_stats":null,"previous_names":["compdfkit/compdfkit-pdf-sdk-apple-package"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ComPDFKit/compdfkit-pdf-sdk-apple-package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-apple-package","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-apple-package/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-apple-package/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-apple-package/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ComPDFKit","download_url":"https://codeload.github.com/ComPDFKit/compdfkit-pdf-sdk-apple-package/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ComPDFKit%2Fcompdfkit-pdf-sdk-apple-package/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268470799,"owners_count":24255391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compdfkit","ios","macos","pdf","pdf-editor","pdf-viewer","swift","swift-package-manager"],"created_at":"2024-11-12T03:17:17.634Z","updated_at":"2025-08-02T23:07:42.752Z","avatar_url":"https://github.com/ComPDFKit.png","language":"Swift","readme":"# ComPDFKit\n\n[ComPDFKit PDF SDK](https://www.compdf.com/) seamlessly operates on [Web](https://www.compdf.com/web), [Windows](https://www.compdf.com/windows), [Android](https://www.compdf.com/android), [iOS](https://www.compdf.com/ios), [Mac](https://www.compdf.com/contact-sales), and [Server](https://www.compdf.com/server), with support for cross-platform frameworks such as [React Native](https://www.compdf.com/react-native), [Flutter](https://www.compdf.com/flutter), etc.\n\n\n\n# Introduction\n\n[ComPDFKit PDF SDK - Apple Package](https://www.compdf.com/ios) is a configuration file tailored for seamless integration of our Swift-based PDF Library into iOS applications. [ComPDFKit PDF SDK - Swift](https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-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.\n\n\n\n# Related\n\n- [ComPDFKit PDF Library for iOS (Objective-C)](https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-objective-c)\n- [ComPDFKit PDF Library for Android](https://github.com/ComPDFKit/compdfkit-pdf-sdk-android)\n- ComPDFKit PDF SDK - [Flutter Library](https://pub.dev/packages/compdfkit_flutter)\n- ComPDFKit PDF SDK - [React Native Library](https://github.com/ComPDFKit/compdfkit-pdf-sdk-react-native)\n- [How to Build an iOS PDF Viewer or Editor in Swift](https://www.compdf.com/blog/build-an-ios-pdf-viewer-or-editor-in-swift)\n- [How to Build an iOS PDF Viewer or Editor in Objective-C](https://www.compdf.com/blog/build-an-ios-pdf-viewer-or-editor-in-objective-c)\n\n\n\n# Getting Started\n\nIt'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.\n\nThe following sections explain how to run integration with Swift Package into your project\n\n\n\n## Requirements\n\n[ComPDFKit PDF SDK - Swift Package](https://www.compdf.com/guides/pdf-sdk/ios/overview) 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. \n\n- The iOS 10.0 or higher.\n- The [Xcode](https://developer.apple.com/xcode/) 13.0 or newer for Objective-C or Swift.\n\n\n\n## Apply the License Key\n\nComPDFKit Apple Package supports flexible licensing options, including online and offline licenses. You can apply for a [free trial license](https://www.compdf.com/pricing) on our website or contact [our sales team](mailto:support@compdf.com) 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.\n\nTo learn how to [copy and apply the license key](https://www.compdf.com/guides/pdf-sdk/ios/apply-the-license-key) and more details about our license, please visit our comprehensive documentation.\n\n\n\n# How to Make an iOS PDF Editor with Swift Package Manager\n\n\n\n## Creating a New Xcode Project\n\n1. Open Xcode and select **File** \u003e **New** \u003e **Project…** to create a new project for your application:\n\n   \u003cimg src=\"image/1.png\" style=\"zoom:50%;\" /\u003e\n\n2. Choose the **App** template for your project:\n\n   \u003cimg src=\"image/2.png\" style=\"zoom:50%;\" /\u003e\n\n3. When prompted, enter your app name (ComPDFKit-Demo) and your organization identifier (com.example) and choose **Storyboard** for the interface:\n\n   \u003cimg src=\"image/3.png\" style=\"zoom:50%;\" /\u003e\n\n4. Click **Next** and select the location to save the project.\n\n5. Click **Create** to finish.\n\n   \n\n## Integrate ComPDFKit Apple Package into SPM\n\n1. Open your application in Xcode and select your project’s **Package Dependencies** tab.\n\n   \u003cimg src=\"image/4.png\" style=\"zoom:50%;\" /\u003e\n\n2. Copy the [ComPDFKit Apple package](https://github.com/ComPDFKit/compdfkit-pdf-sdk-apple-package) repository URL into the search field:\n\n   ```shell\n   https://github.com/ComPDFKit/compdfkit-pdf-sdk-apple-package\n   ```\n\n   \u003cimg src=\"image/5.png\" style=\"zoom:50%;\" /\u003e\n\n3. In the **Dependency Rule** fields, select **Branch** \u003e **master**, and then click **Add Package**.\n\n\u003cimg src=\"image/6.png\" style=\"zoom:50%;\" /\u003e\n\n4. After the package download completes, select **Add Package**.\n\n\n5. ComPDFKit should now be listed under Swift Package Dependencies in the Xcode Project navigator.\n\n\n\n## Display a PDF Document\n\nSo 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.\n\n1. Prepare a test PDF file, drag and drop it into the newly created **PDFView** 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 named `Online5` into the project.\n\n   \u003cimg src=\"image/2-7-2.jpg\" style=\"zoom:50%;\" /\u003e\n\n   \n\n2. Create a `CPDFDocument` object through **NSURL**, and create a `CPDFView` to display it. The following code shows how to load PDF data using a local PDF path and display it by `CPDFView`.\n\n   ```swift\n   guard let filePath = Bundle.main.path(forResource: \"Online5\", ofType: \"pdf\") else { return  }\n   let url = URL(fileURLWithPath: filePath)\n   let document = CPDFDocument(url: url)\n   \n   let rect = self.view.bounds\n   let pdfView = CPDFView(frame: self.view.bounds)\n   pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight]\n   pdfView.document = document\n   ```\n\n3. Add the created `CPDFView` to the view of the current controller. The sample code shows below.\n\n   ```swift\n   self.view.addSubview(pdfView)\n   ```\n\n   The code shown here is a collection of the steps mentioned above:\n\n   ```swift\n   override func viewWillAppear(_ animated: Bool) {\n        super.viewWillAppear(animated)\n           \n        guard let filePath = Bundle.main.path(forResource: \"Online5\", ofType: \"pdf\") else { return  }\n        let url = URL(fileURLWithPath: filePath)\n        let document = CPDFDocument(url: url)\n   \n        let rect = self.view.bounds\n        let pdfView = CPDFView(frame: self.view.bounds)\n        pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight]\n        pdfView.document = document\n        self.view.addSubview(pdfView)\n   }\n   ```\n\n4. Connect your device or simulator, and use shortcut **Command_R** to run the App. The PDF file will be opened and displayed.\n\n   \u003cimg src=\"image/2-7-3-swift.jpg\" style=\"zoom:50%;\" /\u003e\n\n\n\n\n## Add Required Permissions\n\nTo 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.\n\n\u003cimg src=\"image/7.png\" style=\"zoom:50%;\" /\u003e\n\n```objective-c\n\u003ckey\u003eNSCameraUsageDescription\u003c/key\u003e\n\u003cstring\u003eYour consent is required before you could access the function.\u003c/string\u003e\n\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\u003cstring\u003eYour consent is required before you could access the function.\u003c/string\u003e\n\n\u003ckey\u003eNSPhotoLibraryAddUsageDescription\u003c/key\u003e\n\u003cstring\u003eYour consent is required before you could access the function.\u003c/string\u003e\n\n\u003ckey\u003eNSPhotoLibraryUsageDescription\u003c/key\u003e\n\u003cstring\u003eYour consent is required before you could access the function.\u003c/string\u003e\n```\n\n\n\n# Support\n\nComPDFKit has a professional R\u0026D 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.\n\n- For detailed information, please visit our [Guides](https://www.compdf.com/guides/pdf-sdk/ios/overview) page.\n- Stay updated with the latest improvements through our [Changelog](https://www.compdf.com/pdf-sdk/changelog-ios).\n- For technical assistance, please reach out to our [Technical Support](https://www.compdf.com/support).\n- To get more details and an accurate quote, please contact our [Sales Team](https://compdf.com/contact-us).\n\n\n\nThanks,\nThe ComPDFKit Team","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompdfkit%2Fcompdfkit-pdf-sdk-apple-package","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompdfkit%2Fcompdfkit-pdf-sdk-apple-package","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompdfkit%2Fcompdfkit-pdf-sdk-apple-package/lists"}