writefreely-swift/README.md

85 lines
3.4 KiB
Markdown

# WriteFreely
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fwritefreely%2Fwritefreely-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/writefreely/writefreely-swift)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fwritefreely%2Fwritefreely-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/writefreely/writefreely-swift)
A Swift package that wraps the [WriteFreely](https://writefreely.org) 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](https://github.com/SwiftDocOrg/swift-doc). 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:
```bash
$ swift doc generate Sources --module-name WriteFreely --format html --output ./docs
```
### Installing
1. Clone this repository.
2. There is no step two.
## Running the tests
Run the tests from the command line:
```bash
$ swift build
$ swift test
```
## Deployment
Follow the instructions in this [Apple Developer document](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app) to add the `WriteFreely` Swift package to your app.
Once you've done that, just import the library into whichever files should consume it:
```swift
@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:
```swift
guard let instanceURL = URL(string: "https://your.writefreely.host/") else { fatalError() }
let client = WFClient(for: instanceURL)
client.login(username: "username", password: "password", completion: { result in
switch(result) {
case .success():
// Do something with the returned WFUser
case .failure():
// Do something with the returned WFError
}
})
```
See [the API documentation](https://developers.write.as/docs/api/?swift) for more details. Xcode-specific documentation is also available [here](https://writefreely.github.io/writefreely-swift/).
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
Need help getting started? Find out more about the project's [office hours](https://discuss.write.as/t/office-hours-for-writefreely-swift-projects/2788).
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/writeas/writefreely-swift/tags).
## Authors
* **Angelo Stavrow** - *Initial work* - [AngeloStavrow](https://github.com/AngeloStavrow)
See also the list of [contributors](https://github.com/writeas/writefreely-swift/contributors) who participated in this project.
## License
This project is licensed under the BSD 3-Clause License - see the [LICENSE.md](LICENSE.md) file for details.