# AkiProtectSDK — Swift

Swift façade over `libAkiProtectSDK.dylib` (licensing / HWID / activate).

**Markers** (`AKI_PROTECT_BEGIN` / …) stay in C/ObjC — Swift cannot emit the
asm label macros. Put protected regions in a `.c` / `.m` file.

## Option A — Swift Package (SPM)

From `macos/sdk`:

```bash
./build_sdk.sh
cd swift
swift build -Xlinker -L../lib -Xlinker -lAkiProtectSDK \
  -Xlinker -rpath -Xlinker @loader_path/../lib
swift run AkiProtectLicenseSmoke
# optional: AKI_RSA_PUB=../keys/demo.pub AKI_SERIAL='…' swift run …
```

`Package.swift` wires module `CAKiProtect` (clang) → `AkiProtectSDK` (Swift).

## Option B — Xcode app (bridging header)

1. Add `swift/AkiProtect-Bridging-Header.h` as the target’s bridging header.
2. Header Search Paths: path to `macos/sdk` (where `AkiProtectSDK.h` lives).
3. Link `lib/libAkiProtectSDK.dylib`; set rpath / embed if needed.
4. Call C APIs from Swift, or copy `Sources/AkiProtectSDK/AkiProtectSDK.swift`
   into the app and keep the bridging header.

```swift
import Foundation
// After bridging header is set, C symbols are visible; or use the AkiProtect enum:

try AkiProtect.setPublicKeyPath("./keys/demo.pub")
try AkiProtect.setActivationURL("https://akiprotect.core-jmp.org/activate.php")
AkiProtect.setProductCode()
let hwid = try AkiProtect.currentHWID()
try AkiProtect.setSerialNumber(serial)
try AkiProtect.activateOnline(ticketPath: "ticket.aktk")
```

## Env

Same as the C dylib: `AKI_MAC_BUILDER`, `AKI_RSA_PUB`, `AKI_ACTIVATE_URL`.
