Integrating Real-Time Collaboration into Your iOS Application

With PSPDFKit Instant, it’s easier than ever to add real-time collaboration features to your PSPDFKit-powered app, allowing your users to seamlessly share, edit, and annotate PDF documents across Android, iOS, and web apps. This article will guide you through integrating Instant into your own apps.

Requirements

  • PSPDFKit and Instant require the latest stable version of Xcode available at the time the release was made.

  • A PSPDFKit Server instance and one of our example backends. See the Example Projects guide to get an instance up and running.

  • PSPDFKit for iOS and Instant. PSPDFKit, PSPDFKitUI, and Instant are separate frameworks. The frameworks can be integrated into your application via Swift Package Manager or CocoaPods, manually after downloading the latest release from customers.pspdfkit.com, or via Carthage.

Quick Start with the Example Project

Instant comes with a source-available iOS example project, which connects to either one of our example server apps.

  1. Run PSPDFKit Server locally using one of our example projects.

  2. In a web browser, log in to the example app with the same user ID the iOS app uses in AppDelegate.swift, which by default is test.

  3. Add a document to the server using the Upload PDF button.

  4. Select the document to view it with PSPDFKit for Web and add some annotations. You can also create a new layer on the same document to switch between different sets of annotations on the same document.

  5. Open Instant-iOS-Example.xcodeproj in Xcode.

  6. Build and run the Instant-iOS-Example scheme on iOS Simulator. After launching, the app should load the list of all documents with all their respective layers from the server.

  7. Tap any layer in the app to download it and show it in an InstantViewController.

  8. Add annotations in the iOS app or in the browser to see annotation syncing.

ℹ️ Note: To run on an iOS device instead of the simulator, replace localhost in the serverURL and baseURL in AppDelegate.swift with the hostname or address that the server can be reached at. This is your Mac’s local IP address, which you can see by option-clicking the Wi-Fi icon in the macOS menu bar.

Troubleshooting

If Instant-iOS-Example doesn’t build, make sure you’re using the latest stable version of Xcode; expand the Frameworks group in the Project Navigator; and check that the PSPDFKit.xcframework, PSPDFKitUI.xcframework, and Instant.xcframework frameworks aren’t missing. If the app runs but no documents or layers appear, make sure the userID in AppDelegate.swift matches the name you entered in the browser when logging in to the example app and that the server and example app are running on your machine.

Integrating the Instant Framework

There are various ways to integrate the Instant framework.

Swift Package Manager

If you’re already using Swift Package Manager, you can add Instant to your project like so:

  1. Integrate the PSPDFKit Swift package.

  2. Integrate the Instant Swift package using the public repository URL.

https://github.com/PSPDFKit/Instant-SP
Adding the Swift package

CocoaPods

If you’re already using CocoaPods, you can add PSPDFKit and Instant to your project by adding the following to your Podfile:

use_frameworks!

target :YourTargetName do
	pod 'PSPDFKit',
	    podspec: 'https://customers.pspdfkit.com/pspdfkit-ios/latest.podspec'
	pod 'Instant',
	    podspec: 'https://customers.pspdfkit.com/instant/latest.podspec'
end

Then run pod install.

Manual Integration

To integrate manually:

  1. Integrate PSPDFKit.

  2. Drag Instant.xcframework into the Frameworks, Libraries, and Embedded Content section of your target.

Carthage

If you’re already using Carthage, you can add PSPDFKit and Instant to your project by adding the following to your Cartfile:

binary "https://customers.pspdfkit.com/pspdfkit-ios.json"
binary "https://customers.pspdfkit.com/instant.json"

Then run carthage update.