# AkiProtect macOS SDK (v1)

Header markers + `libAkiProtectSDK.dylib` for HWID / serial / online activate.

## Markers (header-only, arm64)

```c
#include "AkiProtectSDK.h"

int secret(int a, int b) {
    AKI_PROTECT_BEGIN(secret);   // or AKI_MUTATE_BEGIN / AKI_ULTRA_BEGIN / AKI_LOCK_BEGIN
    int r = a * 3 + b;
    AKI_PROTECT_END(secret);
    return r;
}
```

Protect:

```bash
aki_mac_builder --virt-markers --codesign adhoc -i ./app -o ./app_p
# mut_/ultra_ markers auto-enable --virt-mutate
```

List regions: `aki_mac_builder --sdk-scan -i ./app`

## Licensing API (dylib)

```bash
./build_sdk.sh          # → lib/libAkiProtectSDK.dylib
```

```c
AkiProtectSetPublicKeyPath("./keys/demo.pub");
AkiProtectSetActivationUrl("https://akiprotect.core-jmp.org/activate.php");
AkiProtectSetProductCode(0x414B4944);

char hwid[128];
AkiProtectGetCurrentHWID(hwid, sizeof hwid);

if (!AkiProtectSetSerialNumber(serial)) {
    fprintf(stderr, "%s\n", AkiProtectGetLastError());
}
AkiProtectActivateOnline("ticket.aktk");  // needs aki_mac_builder on PATH
```

| API | Notes |
|-----|--------|
| `AkiProtectGetCurrentHWID` | `model\|memsize\|ncpu` (stage2 / activate.php) |
| `AkiProtectSetSerialNumber` | verifies via `aki_mac_builder --rsa-verify` when pubkey set |
| `AkiProtectActivateOnline` | host `--activate` |
| `AkiProtectActivateOffline` | `--ticket-from-b32` |

Set `AKI_MAC_BUILDER`, `AKI_RSA_PUB`, `AKI_ACTIVATE_URL` as needed.

After packing, **stage2** owns ticket/serial gates. Ship the dylib only if your **unpacked** app calls these APIs (license UI, activate helper). Marker-only apps need the header alone — no dylib at runtime.

## Link

```bash
clang++ -O0 -I. -L./lib -lAkiProtectSDK \
  -Wl,-rpath,@loader_path/lib -Wl,-headerpad_max_install_names \
  your.cpp -o your_app
```

Small demos should pass `-Wl,-headerpad_max_install_names` (same as our fixtures) so
`__TEXT.__text` is not packed against the Mach-O load commands — the virt pipeline
expects a bit of header pad on tiny binaries.

## Swift

See [swift/README.md](swift/README.md) — SPM package + Xcode bridging header.
Markers remain C/ObjC-only; licensing APIs are wrapped in `AkiProtect` (Swift).