a month later
CR-Soneso changed the title to Stellar iOS SDK .

Hello, I am one of the developers and maintainers of the Soneso Stellar iOS SDK.

Our SDK is a full featured Swift SDK that facilitates integration with the Stellar Horizon API server and submission of Stellar transactions. My team and I spent the past several weeks writing code for it. It is now ready for beta testing.

If you are an iOS developer and interrested in using a native swift sdk for your iOS app or wallet, check out our sdk.

Here are some examples of typical usage:

1. Keypair Generation

// create a completely new and unique pair of keys.
let keyPair = try! KeyPair.generateRandomKeyPair()

print("Account Id: " + keyPair.accountId)
// GCFXHS4GXL6BVUCXBWXGTITROWLVYXQKQLF4YH5O5JT3YZXCYPAFBJZB

print("Secret Seed: " + keyPair.secretSeed)
// SAV76USXIJOBMEQXPANUOQM6F5LIOTLPDIDVRJBFFE2MDJXG24TAPUU7

2. Check Account

sdk.accounts.getAccountDetails(accountId: accountId) { (response) -> (Void) in
    switch response {
    case .success(let accountDetails):
        
        // You can check the `balance`, `sequence`, `flags`, `signers`, `data` etc.
        
        for balance in accountDetails.balances {
            switch balance.assetType {
            case AssetTypeAsString.NATIVE:
                print("balance: \(balance.balance) XLM")
            default:
                print("balance: \(balance.balance) \(balance.assetCode!) issuer: \(balance.assetIssuer!)")
            }
        }

        print("sequence number: \(accountDetails.sequenceNumber)")

        for signer in accountDetails.signers {
            print("signer public key: \(signer.publicKey)")
        }

        print("auth required: \(accountDetails.flags.authRequired)")
        print("auth revocable: \(accountDetails.flags.authRevocable)")

        for (key, value) in accountDetails.data {
            print("data key: \(key) value: \(value.base64Decoded() ?? "")")
        }
    case .failure(let error):
        print(error.localizedDescription)
    }
}

3. Send Payment

// create the payment operation
let paymentOperation = PaymentOperation(sourceAccount: sourceAccountKeyPair,
                                        destination: destinationAccountKeyPair,
                                        asset: Asset(type: AssetType.ASSET_TYPE_NATIVE)!,
                                        amount: 1.5)
                                        
// create the transaction containing the payment operation
let transaction = try Transaction(sourceAccount: accountResponse,
                                  operations: [paymentOperation],
                                  memo: Memo.none,
                                  timeBounds:nil)

// sign the transaction
try transaction.sign(keyPair: sourceAccountKeyPair, network: Network.testnet)

// submit the transaction
try self.sdk.transactions.submitTransaction(transaction: transaction) { (response) -> (Void) in
    switch response {
      case .success(_):
          // ...
      case .failure(_):
          // ...
    }
}

4. Stream Payments

sdk.payments.stream(for: .paymentsForAccount(account: accountId, cursor: nil)).onReceive { (response) -> (Void) in
    switch response {
    case .open:
        break
    case .response(let id, let operationResponse):
        if let paymentResponse = operationResponse as? PaymentOperationResponse {
            switch paymentResponse.assetType {
            case AssetTypeAsString.NATIVE:
                print("Payment of \(paymentResponse.amount) XLM from \(paymentResponse.sourceAccount) received -  id \(id)" )
            default:
                print("Payment of \(paymentResponse.amount) \(paymentResponse.assetCode!) from \(paymentResponse.sourceAccount) received -  id \(id)" )
            }
        }
    case .error(let err):
        ...
    }
}

Github: https://github.com/Soneso/stellar-ios-mac-sdk
Quick Start: https://github.com/Soneso/stellar-ios-mac-sdk#quick-start
Sample app: https://github.com/Block-Equity/stellar-ios-sample-wallet

Testing feedback and all suggestions are welcome. You can create issues here: https://github.com/Soneso/stellar-ios-mac-sdk/issues

5 days later

Hi guys,
thank you for your feedback.

Installation via CocoaPods is now available:

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate stellar SDK into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

target '<Your Target Name>' do
    pod 'stellar-ios-mac-sdk'
end

Then, run the following command:

$ pod install

We also added support for macOS X.

Our next step is the implementation of sep-0005: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md

5 days later

When we first started exploring Stellar for our native iOS Wallet we knew we had to build our own version of a Swift SDK, until we came across this. The core team has done a fantastic job on it and as a result, it has saved us so much development time. It has also encouraged me to directly contribute to the SDK rather than having to build those features directly in our own wallet. I would love to see this being the official Swift SDK for Stellar.

10 days later

Hello,

we have updated our sdk for deterministic key pair generation. Take a look to sep-0005: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md for more details on deterministic key pair generation.

Here is how you can use it in our iOS and macOS SDK:

Generate mnemonic

let mnemonic = Wallet.generate24WordMnemonic()
print("generated 24 words mnemonic: \(mnemonic)")
// bench hurt jump file august wise shallow faculty impulse spring exact slush thunder author capable act festival slice deposit sauce coconut afford frown better

Generate key pairs

let keyPair0 = try! Wallet.createKeyPair(mnemonic: mnemonic, passphrase: nil, index: 0)
let keyPair1 = try! Wallet.createKeyPair(mnemonic: mnemonic, passphrase: nil, index: 1)

print("key pair 0 accountId: \(keyPair0.accountId)")
// key pair 0 accountId: GC3MMSXBWHL6CPOAVERSJITX7BH76YU252WGLUOM5CJX3E7UCYZBTPJQ

print("key pair 0 secretSeed: \(keyPair0.secretSeed!)")
// key pair 0 secretSeed: SAEWIVK3VLNEJ3WEJRZXQGDAS5NVG2BYSYDFRSH4GKVTS5RXNVED5AX7

You can find more info in the project quick start guide: https://github.com/Soneso/stellar-ios-mac-sdk#12-deterministic-generation

a year later