Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

Baza207/TrefleSwiftSDK

Repository files navigation

⚠️ Archived! Please Read First!

Sadly it seems like the Trefle project is over for now, and as I've not had time to work on this SDK myself either I have also decided to archive it. Please visit the main Trefle project for more details: https://github.com/treflehq/trefle-api


TrefleSwiftSDK

Swift Platforms SwiftPM Carthage CocoaPods Twitter

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:

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.

  1. Import TrefleSwiftSDK in your AppDelegate:
import TrefleSwiftSDK
  1. Setup TrefleSwiftSDK by calling configure(accessToken:uri:) in application(_: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>")
  1. 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.

Contributors

James Barrow

License

MIT Licence

About

TrefleSwiftSDK is a Swift wrapper around the Trefle API.

Topics

Resources

License

Stars

Watchers

Forks

Languages