Search code examples
ioscallbackhyperledgerasynccallbackhyperledger-indy

Manage callbacks for Hyperledger Indy iOS SDK


I created a new xCode project (swiftUI) and I followed the guide to install the Indy iOS SDK. Link: https://github.com/hyperledger/indy-sdk/blob/master/wrappers/ios/README.md

The pod has been installed correctly and I can call the various functions offered by the SDK.

I would like to perform the following operations in sequence:

  1. Create a wallet
  2. Open the wallet

I tried to nest the two operations:

let error = indy_create_wallet(0, walletConfig, credentials, {(commandHandle, err) in
        print("Create wallet error: ", err)
        let error = indy_open_wallet(1, self.walletConfig, self.credentials, {(commandHandle2, err2, handle) in
            print("Open wallet error: ", err2)
            
        })
    })

But, in this case I get the error: A C function pointer cannot be formed from a closure that captures context

I tried to use the DispatchGroup but again I get the same error as I have to call the leave() method on the object inside the callback.

Unfortunately I cannot use the "libindy-objc" wrapper because it is not compatible with the version of swift I am using.

Does anyone have any ideas on how I can manage these callbacks to sequentially execute the wallet creation and opening operation? Thanks!


Solution

  • To solve the problem I imported (inside a new group) the wrapper source files.