This repository contains a minimal SwiftUI application demonstrating how to embed the Komodo DeFi Framework (KDF) on iOS. The app starts an instance of kdf (aka mm2) from the libkdf.a static library, polls the local RPC interface for the version string, and optionally enables and monitors a KMD wallet. It features automatic polling in the foreground and background, manual version/balance fetches, log viewing, and local notifications when the KMD balance changes. The latter is demonstrate with the app in BG and the iPhone locked.
- Xcode 15 or later
- iOS 15 or later deployment target
- The KDF static library
libkdf.a(not included in this repo). Placelibkdf.ain the project root and add it to your target’s Link Binary With Libraries phase.
-
Clone the repository and open the
KdfTest.xcodeprojin Xcode. -
Add the static library:
- Copy your
libkdf.afile into the project root (KdfTest/libkdf.a). - In Xcode, select the
KdfTesttarget, go to General → Frameworks, Libraries & Embedded Content, click the “+” button and choose Add Other… → Add Files…, then picklibkdf.afrom the project root. - Ensure it appears under Frameworks, Libraries & Embedded Content.
- Copy your
-
Configure the bridging header:
- The bridging header
KomodoDefiFramework‑Bridging‑Header.himportskomodo_defi_framework.hso Swift can callmm2_main,mm2_main_status, andmm2_stop. - In the target’s Build Settings, set Objective‑C Bridging Header to the relative path of the bridging header (e.g.
KdfTest/KomodoDefiFramework‑Bridging‑Header.hif you havn't moved it and it’s inside theKdfTestfolder). - Ensure the folder containing
komodo_defi_framework.his in Header Search Paths.
- The bridging header
-
Build and run the app on a device. On first launch the app requests notification permission to send local alerts for balance updates.
- Automatic Version Polling – the app calls the
versionRPC method every 10 seconds in the foreground and every 60 seconds in the background. - KMD Wallet Controls – enable or disable the KMD coin, fetch its balance and address, and monitor changes. The app writes a basic (KMD) coin definition to disk and embeds it in the configuration so
mm2knows about KMD. - Logs – view mm2 logs and your own app logs in separate expandable sections.
- Background Operation – when the app goes into the background, a background task keeps the polling timers alive. Note: iOS limits the time a background task may run.
- Local Notifications – you receive a local notification whenever a new/updated KMD balance is fetched.
- The KMD coin is enabled using the legacy
electrumRPC method with cipi's electrum servers. If you wish to enable other coins or change activation parameters, update theenableKmd()call inKdfService.swift. - This project is intended as a demo / integration test; it lacks user‑interface polish and secure handling of secrets. Do not use it as a production wallet!
For more information on Komodo DeFi Framework and RPC methods, see the official documentation: https://komodoplatform.com/en/docs/komodo-defi-framework/.