> 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/core/get-started/languages/obj-c.md).

# Objective-C & macOS PDF library integration

Learn how to run Apryse samples and integrate a free trial of the Apryse SDK into Obj-C applications on macOS. Get unlimited trial usage & support from solution engineers. Download now! The Apryse Ser

This guide will help you [run Apryse samples](#run-the-samples) and [integrate a free trial of the Apryse SDK into Obj-C applications](#integrate-into-your-application) on macOS. Your free trial includes unlimited trial usage and support from solution engineers.

## Prerequisites

* [Xcode](https://developer.apple.com/xcode/)
* Apryse's Objective-C PDF library for macOS:

Download the SDK

{% @apryse-download-button/apryse-download-button id="Objective\_C\_SDK\_core\_mac" showVersion="true" %}

{% hint style="info" %}
**Run Apryse SDK in production**

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 commercial license key confidential.**

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

## Initial setup

1. [Download the Apryse SDK.](#prerequisites)
2. Extract the downloaded zip file and navigate to it.
3. Get your Apryse trial key.

{% @apryse-license-key/apryse-license-key platform="SERVER" variant="full" %}

## Run the samples

**Run a specific sample**

1. Navigate to the `OBJC` folder in a sample project, for example `/Samples/AddImageTest/OBJC` and run the sample with

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

```sh
./RunTest.sh
```

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

**Run all samples**

1. Navigate to `/Samples` and run

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

```sh
./runall_objc.sh
```

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

The tests will run one by one.

{% hint style="info" %}
Output files will be in /Samples/TestFiles/Output
{% endhint %}

## Integrate into your application

This section will show you how to use our SDK to create a simple Apryse "Hello World!" application. It will create a document with one blank page and save it as a [linearized PDF](https://apryse.com/blog/pdf-format/what-is-pdf-linearization) in its running directory.

1. Navigate to the `/Samples` directory of the Apryse SDK and create a directory called `myApp` if it does not exist already. This guide will assume your project is named myApp.
2. Enter your `myApp` directory and create a `OBJC` directory for organization. Then create a `myApp.m` file. Open this file in your favorite text editor and paste:

{% tabs %}
{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
#import <OBJC/PDFNetOBJC.h>
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
    @autoreleasepool {
        int ret = 0;
        [PTPDFNet Initialize: 0];  // PDFNet must be initialized before accessing any Apryse API

        PTPDFDoc* doc = [[PTPDFDoc alloc] init];
        PTPDFRect * rect = [[PTPDFRect alloc] init];
        [rect Set: 0 y1: 0 x2: 612 y2: 792];
        PTPage* page = [doc PageCreate: rect];  // Start a new page
        [doc PagePushBack: page];   // Add the page to the document
        [doc SaveToFile: @"output.pdf" flags: e_ptlinearized];
        NSLog(@"Hello World!");
        return ret;
    }
}
```

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

1. In that same `OBJC` directory inside your myApp project folder add a makefile called `Makefile` and paste this inside:

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

```shell
TESTNAME=myApp
CC=clang
TARGET=$(TESTNAME)
INCLUDES=-I../../../Headers
CFLAGS=-fobjc-exceptions -fobjc-arc
LIBS=-L../../../Lib -lPDFNetC -framework Foundation
LDFLAGS=-Wl,-rpath,../../../Lib

$(TARGET): $(TARGET).m.o
    @echo "Linking target: $(TARGET)"
    $(CC) -o $@ $< $(LIBS) $(LDFLAGS)

$(TARGET).m.o: $(TARGET).m
    @echo "Compiling target: $(TARGET)"
    $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES)

all: $(TARGET)

clean:
    rm -fr $(TARGET) *.o

rebuild: clean all

.PHONY: all clean rebuild
```

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

1. Run the project by executing:followed by:If all goes well, your terminal should output:

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

```sh
make
```

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

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

```sh
./myApp
```

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

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

```sh
PDFNet is running in demo mode.
Permission: write
Hello World!
```

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

Check the `output.pdf` that the program output in the same directory. It should be a PDF with one blank page.

## Next step

<a href="https://github.com/iKettles/apryse-gitbook/tree/main/core/guides/README.md" class="button primary">Guides</a><a href="/core/get-started/readme/api.md" class="button primary">API docs</a><a href="https://github.com/iKettles/apryse-gitbook/tree/main/samples/README.md" class="button primary">Samples</a>


---

# 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/core/get-started/languages/obj-c.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.
