> 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/xamarin/learn-more/code-sharing.md).

# Code sharing between Xamarin.Android app and Xamarin.iOS app

Learn how to structure your Xamarin project for code sharing with Apryse SDK. Shared classes for Xamarin.Android and Xamarin.iOS, including creating sticky note annotations. Optimize code sharing betw

## Shared classes

Apryse for Xamarin SDK takes advantage of PInvoke which allows calling C functions from C# directly. As a result, majority of Apryse classes share the same API between Xamarin.Android and Xamarin.iOS. For example, you can find `AndroidMiscellaneousSamples` and `iOSMiscellaneousSamples` in the download packages which share all of their source code.

This guide demonstrates how to structure your project to allow code sharing. Platform specific classes will be listed at the end of this guide.

First, create a `Common` folder outside of both apps, for example:

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

```sh
MyProject/
    |__Common/
    |__MyAndroidApp/
    |__MyiOSApp/
```

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

`Common` folder will be where all the shared source files live. For example, let's say we have a `Common/CreateSticky.cs` file for creating sticky note annotations.

Now, when open each of the Xamarin.iOS or Xamarin.Android project in Visual Studio, add `CreateSticky.cs` as a linked item:

In Visual Studio for Mac:

* Right click on the project
* Click **Add** > **Add Files...**
* Select `Common/CreateSticky.cs`
* Choose `Add a link` in the `Add File To Folder` dialog

In Visual Studio 2017:

* Right click on the project
* Click **Add** > **Existing item...**
* Select `Common/CreateSticky.cs`, in the same dialog, instead of `Add` button, click the down arrow and select `Add As Link`

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-7a38ae50f9450435bd8d0f1d93a095a54421a72d%2Fd3f5ba814bbd9920f1927cc91d4aee9e42a88899-222x132.png?alt=media)

And that is it! You can use Apryse `pdftron.PDF.Annot` class to create the sticky note in a file that is now shared between Xamarin.Android and Xamarin.iOS apps.

## Platform specific classes

List of platform specific classes:

* `pdftron.PDF.PDFViewCtrl`
* All classes under `pdftron.PDF.Tools` namespace
* All classes under `pdftron.PDF.Controls` namespace


---

# 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/xamarin/learn-more/code-sharing.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.
