> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/ios/learn-more/initialize.md).

# Add license key

Learn how to initialize PDFNet with a license key in Swift projects using storyboards. Ensure proper PDFNet setup before making API calls. Get step-by-step instructions here! The Apryse iOS SDK stream

*This guide demonstrates how to initialize PDFNet with a license key. To begin working with PDFNet, you must have first* [*added it to your project*](/ios/get-started/get-started.md)*.*

1. Import PDFNet.If you have not already done so, import PDFNet to make it accessible.Importing PDFNet. The equivalent in Objective-C is `#import`.

![](https://4149080208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgY6xtY9ZQd9XMpvWlGM0%2Fuploads%2Fgit-blob-6d33854132c16d8b2d1a19c6eacebc7c0b19dd71%2Fb5b012120a7d820941ff29231b8b84d21febda38-1920x1308.png?alt=media)

1. PDFNet must be initialized before any other PDFNet API calls are made. This only needs to be done once. If you have a commercial license key, it must be passed in to the initialize method. (An invalid key will result in the library running in demo mode.) Initializing PDFNet is done as shown:

{% hint style="info" %}
**No trial license key required.**

The trial of Apryse Mobile SDK does not require a trial key. A commercial license key is required for use in a production environment. Please [contact sales](https://apryse.com/form/contact-sales) to purchase a commercial key or if you need any other license key assistance.
{% endhint %}

{% hint style="warning" %}
**Keep your license keys confidential.**

License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).
{% endhint %}

## Initializing PDFNet in a Swift project that uses storyboards

The app lifecycle in a Swift project that uses storyboards is different than other iOS projects, they require careful handling to ensure PDFNet is initialized before its classes are used.

In Swift projects that use storyboards, non-optional stored properties that are instantiated at the point of declaration are instantiated before most code has a chance to run, including [`application(_:willFinishLaunchingWithOptions:)`](https://developer.apple.com/uikit/uiapplicationdelegate/1623032-application/). This means that even if you initialize PDFNet with a license key in this method, which is "[your app’s first chance to execute code at launch time](https://developer.apple.com/library/content/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html)", it will result in an error.

To initialize PDFNet *before*`application(_:willFinishLaunchingWithOptions:)`, add a new property in `AppDelegate.swift` that is initialized with the result of a call to PDFNet's initialize method (which is `void`):

{% tabs %}
{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    private let pdfnetInitialize = PTPDFNet.initialize("Insert commercial license key here after purchase")

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }
```

{% endcode %}
{% endtab %}
{% endtabs %}

Alternatively, non-optional stored properties could be instantiated in the class's `init` functions, in which case `application(_:willFinishLaunchingWithOptions:)` will be run first.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/ios/learn-more/initialize.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
