-
Notifications
You must be signed in to change notification settings - Fork 66
RxSwift Extension
CoinbaseSDK provides an extension to use it with RxSwift.
If you use CocoaPods
, add 'CoinbaseSDK/RxSwift'
pod into your Podfile
:
pod 'CoinbaseSDK', '~> 1.0'
pod 'CoinbaseSDK/RxSwift', '~> 1.0'
In the source file where you want to use CoinbaseSDK with Rx wrappers add:
import CoinbaseSDK
If you use Carthage
, add "coinbase/coinbase-ios-sdk"
dependency reference into your Cartfile
:
github "coinbase/coinbase-ios-sdk"
Run carthage update
to build the framework and drag the built CoinbaseSDK.framework
and RxCoinbaseSDK.framework
into your Xcode project.
In the source file where you want to use RxSwift wrappers add:
import CoinbaseSDK
import RxCoinbaseSDK
Once you have your Swift package set up, add "https://github.com/coinbase/coinbase-ios-sdk"
dependency reference in dependencies
value of your Package.swift
:
dependencies: [
.package(url: "https://github.com/coinbase/coinbase-ios-sdk")
]
Also in Package.swift
add "RxCoinbaseSDK"
to the dependencies
of the specific target
where you want to use RxSwift wrappers:
targets: [
.target(
name: "project_name",
dependencies: ["CoinbaseSDK", "RxCoinbaseSDK"]),
]
In the source file where you want to use RxSwift wrappers add:
import CoinbaseSDK
import RxCoinbaseSDK
Swift Package Manager currently does not support resources. CoinbaseSDK requires additional resource files to work properly (Trusted SSL Certificates). If you want to use Swift Package Manager you should provide those resources manually.
You can find the required resources in Coinbase iOS SDK GitHub repository under Source/Supporting Files/PinnedCertificates
path. Collect those files and add them to your project.
-
Using Xcode:
You should additionally configure
CoinbaseSDK
target. In tabBuild Phases
add new phase by selectingNew Copy File Phase
. Drag and Drop required resources to this phase. -
Using console:
To provide the required resources you should copy them to a location with built files.
Example: If required files are located in directory
Resources
and you building forx86_64-apple-macosx10.10
platform indebug
mode then resources can be copied with the command:cp Resources/* ./.build/x86_64-apple-macosx10.10/debug
Rx extension for CoinbaseSDK provides methods to make API calls wrapped in Single<Element>
.
All available Rx methods have rx_
prefix naming pattern.
E.g. for transactionResource.list()
method Rx wrapper would be transactionResource.rx_list()
:
coinbase.transactionResource
.rx_list(accountID: <account_id>,
expandOptions: [.from, .to]))
.subscribe(onSuccess: { transactions in ... },
onError: { error in ...})
.disposed(by: disposeBag)