SwiftYNAB is a Swift framework for iOS/macOS/watchOS/tvOS/Linux for accessing the You Need a Budget API. It currently supports all endpoints made available by the API.
You can browse the online documentation here to see what features this framework offers.
Instructions on how to add a Swift Package dependency to your project can be found here.
The project comes with a small iOS demo that shows you how to use the framework. If you want to try that out, or if you want to write your own code, you will need a personal API access token.
Make sure you go here and get one:
https://api.youneedabudget.com/#personal-access-tokens
Once you have your personal access token, you can use it to try out the framework in your app. Start by creating a new project and at the top of the file where you plan to use SwiftYNAB, add:
import SwiftYNABThen, you can try it out by writing something like:
let ynab = YNAB(accessToken: "TOKEN_GOES_HERE")
Task {
do {
let budgets = try await ynab.budgets.budgets(includeAccounts: false)
for budget in budgets {
print(budget.name)
}
} catch {
print("Uh oh, something went wrong")
}
}If you want to build and test the code yourself, you can check out this repository and open it directly in Xcode. From there, you can edit the source code and run the tests.
In order to run the built-in demo app, make sure you don't have the SwiftYNAB package open in Xcode, then open the demo app in Xcode from the demo directory. You should be able to run it in your simulator and take it for a spin.
In order to run the linters, or generate documentation, and to take advantage of the pre-commit hooks, you should:
- Install
mise - Once
miseis installed successfully, runmise installto install all of the project dependencies - Run
mise run bootstrapto setup the project for development - Run
mise runto see the available, pre-configured tasks