<commit_before># Swift getting started
​
[Install](https://swift.org/download/#releases) Swift if you haven't done it yet.
​

# Create Swift package
​
```shell
mkdir SwiftClientTest
cd SwiftClientTest
swift package init
```
​
# Add dependency
​
Open the Package.swift with Xcode or your favorite text editor

Set platform and add Swift Client dependency to your package.
Your package.swift must look as follows:

```swift
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

let package = Package(
    name: "SwiftClientTest",
    platforms: [.macOS(.v10_12)],
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "SwiftClientTest",
            targets: ["SwiftClientTest"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(url:"https://github.com/algolia/algoliasearch-client-swift", .branch("feat/v2/transport")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "SwiftClientTest",
            dependencies: []),
        .testTarget(
            name: "SwiftClientTestTests",
            dependencies: ["SwiftClientTest"]),
    ]
)
```

Fetch Swift client dependency by launching

```shell
swift package resolve
```

# Make your package executable
```shell
echo 'print("Hello world!")' > ./Sources/SwiftClientTest/main.swift
```

# Test the execution of your package by running

```shell
swift run
```

You are all set to play with the Swift API Client

## Add Employee structure in a new file
​
```swift
struct Employee: Codable, CustomStringConvertible {
  let company: String
  let name: String
  
  var description: String {
    return "(company: \(company) name: \(name))"
  }
}
```
​
## Index datas
​
Download [Employees.swift](https://github.com/algolia/algoliasearch-client-swift/blob/feat/v2/transport/Tests/AlgoliaSearchClientSwiftTests/Misc/Employees.swift) to `./Sources/SwiftClientTest/.` folder

## Test snippets

Test your snippets in `main.swift`

```swift
import AlgoliaSearchClientSwift
import Foundation

let client = Client(appID: %appID, apiKey: %apiKey)
let index = client.index(withName: %indexName)

var settings = Settings()
settings.attributesForFaceting = [.searchable("company")]

// Read employees list from json string
let employees = try! [Employee](jsonString: Resource.employees)
// Save your info in the index
let me = Hit<Employee>(objectID: %yourObjectID, object: .init(company: "Algolia", name: %yourName))
```
​
## How to test my snippets?
​
```shell
swift run
```
​
Or open your Package.swift with **Xcode** and run it with Cmd+R.
​
All the methods are provided in synchronous and asynchronous version. 
Copy-paste these snippets to your main.swift and call them.<commit_msg>Typos fix<commit_after># Swift getting started
​
[Install](https://swift.org/download/#releases) Swift if you haven't done it yet.
​

# Create Swift package
​
```shell
mkdir SwiftClientTest
cd SwiftClientTest
swift package init
```
​
# Add dependency
​
Open the Package.swift with Xcode or your favorite text editor

Set platform and add Swift Client dependency to your package.
Your package.swift must look as follows:

```swift
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

let package = Package(
    name: "SwiftClientTest",
    platforms: [.macOS(.v10_12)],
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "SwiftClientTest",
            targets: ["SwiftClientTest"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(url:"https://github.com/algolia/algoliasearch-client-swift", .branch("feat/v2/transport")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "SwiftClientTest",
            dependencies: []),
        .testTarget(
            name: "SwiftClientTestTests",
            dependencies: ["SwiftClientTest"]),
    ]
)
```

Fetch Swift client dependency by launching

```shell
swift package resolve
```

# Make your package executable
```shell
echo 'print("Hello world!")' > ./Sources/SwiftClientTest/main.swift
```

# Test the execution of your package by running

```shell
swift run
```

You are all set to play with the Swift API Client

## Add Employee structure in a `./Sources/SwiftClientTest/Employee.swift' file
​
```swift
struct Employee: Codable, CustomStringConvertible {
  let company: String
  let name: String
  
  var description: String {
    return "(company: \(company) name: \(name))"
  }
}
```
​
## Index datas
​
Download [Employees.swift](https://github.com/algolia/algoliasearch-client-swift/blob/feat/v2/transport/Tests/AlgoliaSearchClientSwiftTests/Misc/Employees.swift) to `./Sources/SwiftClientTest/.` folder

## Test snippets

Test your snippets in `main.swift`

```swift
import Foundation
import AlgoliaSearchClientSwift

let client = Client(appID: %appID, apiKey: %apiKey)
let index = client.index(withName: %indexName)

var settings = Settings()
settings.attributesForFaceting = [.searchable("company")]

// Read employees list from json string
let employees = try! [Employee](jsonString: Resource.employees)
// Save your info in the index
let me = Hit<Employee>(objectID: %yourObjectID, object: .init(company: "Algolia", name: %yourName))
```
​
## How to test my snippets?
​
```shell
swift run
```
​
Or open your Package.swift with **Xcode** and run it with Cmd+R.
​
All the methods are provided in synchronous and asynchronous version. 
Copy-paste these snippets to your main.swift and call them.
{'fraction_non_alphanumeric': 0.11149015351217242, 'fraction_numerical': 0.0034113816095518684, 'mean_word_length': 3.6170365068002863, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5140789', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1780, 'n_words': 680}