> For the complete documentation index, see [llms.txt](https://docs.abtasty.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-quick-start.md).

# Quick-start

### Installation

You will find all instructions in [installation](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-installation.md) topic

### Flagship Usage

#### Start SDK

The first call you should make is to start the SDK by calling `start` method through the Flagship singleton.

```groovy
import Flagship

// Step 1 - Start the Flagship sdk with default configuration.
Flagship.sharedInstance.start(envId: "_ENV_ID_", apiKey: "_API_KEY_")
        
```

In *step 1* The SDK needs to start the `environmentId` and `apiKey`. By default the Flagship start with `Decision Mode` for more details on custom configuration go to [Advanced Configuration](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#configuration).

{% hint style="info" %}
📘 API Key & Environment ID required

*You can find your apiKey and your environmentId on your Flagship account, in Parameters > Environment & Security.*
{% endhint %}

#### Create Visitor

The second step after starting the SDK is [visitor](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#visitor-class) creation. This object allows you to manage visitor's context, experiments, and track events.

```groovy
// Step 2 - Create visitor with context "isVip" : true
let visitor = Flagship.sharedInstance.newVisitor(visitorId: "visitorId", hasConsented: true)
              .withContext(context: ["isVip": true])
              .build()

```

In *Step 2* We create a visitor providing his [consent](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#setconsent-method) and his [context](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#updatecontext-method). Go to[ builder methods](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#visitor-builder-methods) to learn more about visitor creation.

#### Getting flags

Once we have created our visitor instance, we need to fetch flags. Go to [Flag](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#flag-class) to learn more about it.

```groovy
// Step 3 - Fetch flags
visitor.fetchFlags {
  
    // Fetch completed
  
    // Step 4 - Get Flag key
    let flag = visitor.getFlag(key: "flagKey")
      
    // Step 5 - Read Flag value
    let value = flag.value(defaultValue: "defaultValue")
}
```

When flag fetching completes in step 3, its inner code block is executed. In step 4, we are ready to process visitors' flags and read their [values](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#getvalue-method) in step 5.

Note: SDK will [report exposition](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#visitorexposed-method) by default when reading a flag value.

#### Tracking hits

Then sending event tracking will allow you to validate objectives in your campaign reporting.

```groovy
// Step 6 - Send Event
visitor.sendHit(FSEvent(eventCategory: .Action_Tracking, eventAction: "event_action"))
```

{% hint style="info" %}
📘

In order to see your events in your campaign reporting you must define objectives kpis beforehand in the campaign configuration.
{% endhint %}

In *step 6,* Flagship is in charge of sending the *event\_action* event through the function `sendHit`. Go to [tracking](https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-reference.md#hit-tracking) for more information.

You should see your hit using [hitStream](https://docs.abtasty.com/flagship-deprecated/reporting/verifying-your-hit-setup.md) feature and then on your campaign [report](https://docs.abtasty.com/flagship-deprecated/reporting/verifying-your-hit-setup.md).


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.abtasty.com/server-side/sdks/ios/archived-versions/ios/swift-quick-start.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
