---
product: Chilkat
product_version: 11.7.0
language: swift
language_label: Swift
document: language guide
---
> Chilkat 11.7.0 · language=swift · this file: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/swift/guide.md`
> Class pages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/swift/classes/<Class>.md`

# Chilkat for Swift — language guide — v11.7.0

## 1. Which Chilkat binding this is

This is the **Chilkat library for Swift** on iOS and macOS: the Objective-C classes `CkoHttp`, `CkoZip`, `CkoBinData`, … used from Swift through a bridging header; created with `CkoHttp()!`, camelCase methods (`http.quickGetStr(url)`), properties as Swift properties. Static libraries (universal for Apple Silicon and Intel on macOS; iOS device and simulator).

## 2. Install and requirements

Download the iOS or macOS library from [https://www.chilkatsoft.com/downloads_ios.asp](https://www.chilkatsoft.com/downloads_ios.asp) / [https://www.chilkatsoft.com/downloads_objc.asp](https://www.chilkatsoft.com/downloads_objc.asp), add the static library and headers to the Xcode project, and import the needed `CkoXxx.h` headers in the bridging header.

## 3. Unlocking and object creation

```swift
// Required once per process, before any other Chilkat object. Any string unlocks a 30-day trial.
let glob = CkoGlobal()!
let success = glob.unlockBundle("Anything for 30-day trial")
if success != true {
    print("\(glob.lastErrorText!)")
    return
}

let http = CkoHttp()!
```

- Unlocking only sets a flag in memory: no license files, no network call, so the call is repeated each time the program runs. Extra calls are harmless no-ops; the `Global` object can be discarded afterwards.
- If a program forgets to unlock, Chilkat runs in trial mode and stops working when the trial expires — always include the call, and use the purchased unlock code in production.
- `UnlockBundle` unlocks every class; per-class `UnlockComponent` methods exist only in old code.

## 4. Error model

Chilkat methods **do not throw**. The note under each method on the class page says how it reports failure: a `Bool` status method returns `false`; a string-returning method returns `nil`; an object-returning method returns `nil`; for an `Int` result check `lastMethodSuccess`. `lastErrorText` holds the diagnostic in every case.

Literals in Swift: true is `true`, false is `false`, null/none is `nil`.

## 5. Strings, bytes and encodings

- Strings are Swift `String` (bridged from `NSString`); a `charset` argument names the encoding of the *bytes* being produced or read.
- Binary data is `Data`/`NSData` in and out; larger or reusable data goes through `CkoBinData` (`…Bd` methods) and text through `CkoStringBuilder` (`…Sb` methods).
- Methods with `2`/`3` suffixes or `quick…` prefixes are distinct members, not overloads.

## 6. Object lifetime and threading

Objects are released by ARC.

A Chilkat object may be used from any thread, but **one object must not be used by two threads at the same time**: create one object per thread or protect it with a lock. Objects are independent — there is no shared global state other than the unlock flag and the few `Global` settings.

## 7. Progress callbacks and async

Progress events are supported: see the "Events and callbacks" section of a class page for the event list and how to attach a handler in this binding (AbortCheck, PercentDone, ProgressInfo and TaskCompleted are the standard ones). Every method with an "Async variant" line also has an `XAsync` twin that returns a `Task` immediately; poll `Finished` or use the `TaskCompleted` event, then read the result from the task. No new Async methods are added from 11.7.0 on. In Swift, implement the class's progress protocol (e.g. `CkoHttpProgress`) and assign the delegate to `EventCallbackObject`; see the "Events and callbacks" section of a class page.

## 8. Common mistakes an AI makes with this binding

1. Using `CkHttp` (C++) or `Chilkat.Http` (.NET) spelling — the Apple classes are `CkoHttp`, created with `CkoHttp()!`.
2. Using PascalCase method names; Swift members are camelCase (`quickGetStr`, `lastErrorText`).
3. Omitting `Global.UnlockBundle` (the program runs in trial mode and stops working after 30 days).
4. Inventing members by analogy with other libraries. If a member is not on the class page, it does not exist — look it up rather than guessing.
5. Using deprecated members that older examples still show. The class page lists each one with its replacement; `deprecated.md` lists them all.
6. Ignoring the failure path. Every Chilkat method reports failure (see each method's note); `LastErrorText` says why, and printing it is the first debugging step.
7. Using one Chilkat object from two threads at the same time. Create one object per thread, or protect it with a lock.

## 9. Instructions block for coding agents

Paste into `CLAUDE.md`, `.cursor/rules`, or Copilot instructions:

```
This project uses Chilkat 11.7.0 from Swift (the Chilkat Objective-C library through a bridging header; classes CkoHttp etc., camelCase members).
- Reference: https://www.chilkatsoft.com/ai-docs/v/11.7.0/swift/ — read guide.md once, then classes/<Class>.md for each class used.
- Call CkoGlobal()!.unlockBundle(...) once at startup.
- Chilkat methods never throw: check the false/nil result and print obj.lastErrorText.
- Never use a member that is not on the class page; never use members listed as deprecated.
```

## 10. Classes

[Class index for Swift](https://www.chilkatsoft.com/ai-docs/v/11.7.0/swift/index.md)
