# TransloaditKit

[transloadit/transloaditkit](https://github.com/transloadit/transloaditkit)

It's easy to start using Transloadit in Objective-C and Swift using CocoaPods or Carthage and leverage file uploading & encoding in macOS and iOS apps.

## Install

### CocoaPods

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```ruby
pod 'Transloadit', '~> 3.0'

```

### Swift Package Manager

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```swift
dependencies: [
    .package(url: "https://github.com/transloadit/TransloaditKit", .upToNextMajor(from: "3.0.0"))
]

```

## Usage

Start by initializing `Transloadit`.

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```swift
let credentials = Transloadit.Credentials(key: "SomeKey", secret: "SomeSecret")
let transloadit = Transloadit(credentials: credentials, session: URLSession.shared)

```

### Create an Assembly

To create an `Assembly` you invoke `createAssembly(steps:andUpload:completion)` on `Transloadit`. It returns a `TransloaditPoller` that you can use to poll for the `AssemblyStatus` of your `Assembly`.

![](/_next/static/media/copy.04p1cju9qekk_.svg?dpl=dpl_CtwzFbHWtqiCy9uvWb9fE7WvfP9N)

```swift
let resizeStep = Step(
    name: "resize",
    robot: "/image/resize",
    options: [
        "width": 200,
        "height": 100,
        "resize_strategy": "fit",
        "result": true])

let filesToUpload: [URL] = ...
transloadit.createAssembly(steps: [resizeStep], andUpload: filesToUpload) { result in
    switch result {
    case .success(let assembly):
        print("Retrieved \(assembly)")
    case .failure(let error):
        print("Assembly error \(error)")
    }
}.pollAssemblyStatus { result in
    switch result {
    case .success(let assemblyStatus):
        print("Received assemblystatus \(assemblyStatus)")
    case .failure(let error):
        print("Caught polling error \(error)")
    }
}

```

## Documentation

See [GitHub](https://github.com/transloadit/TransloaditKit#readme) for the full documentation.
