You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Swift package that wraps the WriteFreely API, for use in your Swift projects.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing
purposes. See Deployment for notes on how to add the library to your app.
Prerequisites
You'll need Xcode 11.5 / Swift 5.2 installed along with the command line tools to work on this package.
Additionally, documentation is generated by SwiftDoc. After making any
changes to the package's public API, you'll need to regenerate the docs; to do so, run the following commands in the
terminal from the root directory of the package:
$ swift doc generate Sources --module-name WriteFreely --format html --output ./docs --base-url https://writefreely.github.io/writefreely-swift/
Installing
Clone this repository.
There is no step two.
Running the tests
Run the tests from the command line:
$ swift build
$ swift test
Deployment
Follow the instructions in this Apple Developer document to add the WriteFreely Swift package to your app.
Once you've done that, just import the library into whichever files should consume it:
@import Foundation // Or UIKit, Cocoa, &cet.
@import WriteFreely
// The rest of the Swift file goes here
Use public methods on the WFClient to send and receive data from the server. The methods leverage completion blocks
and the Result type, so you'd call them like so:
guardlet instanceURL =URL(string:"https://your.writefreely.host/")else{fatalError()}letclient=WFClient(for: instanceURL)
client.login(username:"username", password:"password", completion:{ result inswitch(result){case.success():
// Do something with the returned WFUser
case .failure():
// Do something with the returned WFError
}})