Integrating PSPDFKit with CocoaPods

Table of contents

    Integrating PSPDFKit with CocoaPods

    CocoaPods(opens in a new tab) is a popular dependency manager for Swift and Objective-C projects, and you can use it to integrate PSPDFKit into your project. Using CocoaPods is easier than manually adding the PSPDFKit frameworks to your project.

    Installing CocoaPods

    CocoaPods is available as a Ruby gem you can install by running gem install cocoapods. Using the default Ruby available on macOS can require you to use sudo when installing CocoaPods: sudo gem install cocoapods. To avoid this, we recommend using a Ruby version manager like rbenv(opens in a new tab).

    Integrating PSPDFKit into Your Project

    To begin integration, first create a Podfile next to your Xcode project by running pod init. A Podfile describes the dependencies of the targets of your Xcode project. The content of your Podfile should look like this (change YourTargetName to the target of your app):

    use_frameworks!
    target :YourTargetName do
    pod 'PSPDFKit',
    podspec: 'https://my.nutrient.io/pspdfkit-ios/latest.podspec'
    end

    Now you can run pod install in the directory of your Podfile to install all new pods. This will download PSPDFKit and integrate it into your project. It will also create a new Xcode workspace that you will have to use in place of the original Xcode project.

    Verifying the Integration

    Open the newly created Xcode workspace and import both PSPDFKit and PSPDFKitUI into any of your source files:

    import PSPDFKit
    import PSPDFKitUI
    @import PSPDFKit;
    @import PSPDFKitUI;

    Build and run your target. That’s it! PSPDFKit has been successfully integrated into your project.

    Next Steps

    You can start by checking out our API(opens in a new tab) and documentation. To learn more about CocoaPods, take a look at the official CocoaPods documentation(opens in a new tab). Feel free to reach out to us if you run into any problems or have questions. We’re happy to help!

    Julian Grosshauser

    Julian Grosshauser

    Explore related topics

    FREE TRIAL Ready to get started?