> 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/ios-1/swift-quick-start.md).

# Quick-start

### Installation

You will find all instructions in [installation](/server-side/sdks/ios/ios-1/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](/server-side/sdks/ios/ios-1/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](/server-side/sdks/ios/ios-1/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](/server-side/sdks/ios/ios-1/swift-reference.md#setconsent-method) and his [context](/server-side/sdks/ios/ios-1/swift-reference.md#updatecontext-method). Go to[ builder methods](/server-side/sdks/ios/ios-1/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](/server-side/sdks/ios/ios-1/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](/server-side/sdks/ios/ios-1/swift-reference.md#getvalue-method) in step 5.

Note: SDK will [report exposition](/server-side/sdks/ios/ios-1/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](/server-side/sdks/ios/ios-1/swift-reference.md#hit-tracking) for more information.

You should see your hit using [hitStream](/flagship-deprecated/reporting/verifying-your-hit-setup.md) feature and then on your campaign [report](/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 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.abtasty.com/server-side/sdks/ios/ios-1/swift-quick-start.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.
