TrefleSwiftSDK
TrefleSwiftSDK is a Swift wrapper around the Trefle API.
This is currently a work in progress. There is a list of currently supported features listed below.
- Authentication
- Kingdoms
- Subkingdoms
- Divisions
- Families
- Genus
- Plants
- Species
- Distribution Zones
- Operation support
- Combine support
- Full error handling
- Basic test suite
- Deep test suite
Note: The current version of TrefleSwiftSDK is based on Trefle 1.6.0.
Prerequisites
Before you begin, ensure you have met the following requirements:
- Create a Trefle account at: https://trefle.io
- Once you've created your account and confirmed it via the confirmation email, you will be able to access your "Access Token" at https://trefle.io/profile
Installation
Swift Package Manager
To integrate TrefleSwiftSDK into your Xcode project using Swift Package Manager, add TrefleSwiftSDK as a dependency to the dependencies value of your Package.swift.
dependencies: [
.package(url: "https://github.com/Baza207/TrefleSwiftSDK.git", .upToNextMajor(from: "0.1.0"))
]Carthage
To integrate TrefleSwiftSDK into your Xcode project using Carthage, specify it in your Cartfile with the following:
github "Baza207/TrefleSwiftSDK" "0.1.0"
CocoaPods
To integrate TrefleSwiftSDK into your Xcode project using CocoaPods, specify it in your Podfile with the following:
pod 'TrefleSwiftSDK', '~> 0.1.0'Usage
Basic Setup
Once you have a access token from your Trefle Profile you will also need to create an URI in your Xcode project. To do this you can follow the steps to Register Your URL Scheme in the Apple documentation.
Once you have this, you can import the TrefleSwiftSDK framework in your project and set it up for use.
- Import
TrefleSwiftSDKin yourAppDelegate:
import TrefleSwiftSDK- Setup
TrefleSwiftSDKby callingconfigure(accessToken:uri:)inapplication(_:didFinishLaunchingWithOptions:), passing in your access token from your Trefle Profile as well as the URI you setup in Xcode Info tab.
Trefle.configure(accessToken: "<Access Token>", uri: "<Redirect URI>")- You can then use all the fetch and search calls from any of the managers in the project. All the authentication is handled by the framework using the given access token, meaning you don't have to worry about logging in users or logging them out. All the JWT autnetication and re-authentication on expired tokens is done automatically.