RubyMotion

PSPDFKit for iOS can be used from RubyMotion. We cannot offer support for RubyMotion-specific issue or give out Ruby-based samples, but we try to help you getting started with this:

As RubyMotion currently does not yet support iOS dynamic frameworks via motion-cocoapods, you can use following method to integrate the SDK:

  1. Place PSPDFKit.framework and PSPDFKitUI.framework it into the vendor directory.
  2. Add this to your Rakefile:
1
2
app.embedded_frameworks << 'vendor/PSPDFKit.framework'
app.embedded_frameworks << 'vendor/PSPDFKitUI.framework'

Here's a minimal example:

Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class AppDelegate
  def application(application, willFinishLaunchingWithOptions:launchOptions)
    PSPDFKit.licenseKey = "YOUR_LICENSE_KEY_GOES_HERE"
  end

  def application(application, didFinishLaunchingWithOptions:launchOptions)
    documentURL = NSBundle.mainBundle.resourceURL.URLByAppendingPathComponent "PSPDFKit 5 QuickStart Guide.pdf"
    @document = PSPDFDocument.alloc.initWithURL documentURL

    rootViewController = PSPDFViewController.alloc.initWithDocument @document
    navigationController = UINavigationController.alloc.initWithRootViewController(rootViewController)

    @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
    @window.rootViewController = navigationController
    @window

    true
  end
end

Make sure your Rakefile also includes the application bundle ID:

app.identifier = 'com.yourCompany.yourApp'

To prepare your app for App Store submission you can use the following Rake task:

Copy
1
2
3
4
5
6
7
8
9
10
11
12
task "build:device" do
  env = {
    EXPANDED_CODE_SIGN_IDENTITY_NAME: App.config.codesign_certificate,
    EXPANDED_CODE_SIGN_IDENTITY: App.config.codesign_certificate,
    VALID_ARCHS: App.config.archs['iPhoneOS'].join(','),
    BUILT_PRODUCTS_DIR: File.join(App.config.versionized_build_dir('iPhoneOS'), App.config.bundle_filename),
    FRAMEWORKS_FOLDER_PATH: 'Frameworks',
    CODE_SIGNING_REQUIRED: true,
    CONFIGURATION_BUILD_DIR: App.config.versionized_build_dir('iPhoneOS')
  }
  sh "env #{env.map { |k,v| "#{k}=\"#{v}\"" }.join(' ')} sh vendor/PSPDFKit.framework/strip-framework.sh"
end

The strip-framework.sh script works around an App Store submission bug triggered by universal binaries.