I created this as a side project and also to help a friend manage sales at her small cafe in Wat Phnom, Phnom Penh. It was built with SwiftUI intended for iPad use. The app can manages orders, calculates change based on the dual KHR/USD currency used in Cambodia, as well as generating daily sales reports. It is also capable of connecting to a bluetooth printer to issue receipts. The app is currently distributed ad hoc as I am currently based in Sydney. Further improvements and features are currently being developed.
- A device running MacOS Catalina or greater and
- An iPad with iOS13 or greater to be able to compile and run the code.
- KKmoon POS-5802DD portable thermal printer if you wish to test the printing functionality. (https://www.amazon.com.au/KKmoon-POS-5802DD-Portable-Wireless-Printing/dp/B01MY9H22U)
Simply pull this repo, open it onto Xcode 11 or later and run on a compatible device or simulator. Note that the simulator will not have bluetooth functionality.
This app was built mainly with SwiftUI. Features of Swift it utitlises:
It uses Swift's Codable protocol to create and encode orders to JSON files. Orders are stored in folders ordered by yyyy/mon/dd.
These were used to display order properties as well as pass order items across multiple views and reusable component.
CoreBluetooth was used to establish a connection with the receipt printer and issue receipts.
With the help of Keychain Wrapper, the Keychain framework is used to store app passcode which grants access to the admin page. This page allows users to view financial reports regarding the cafe.
Paul Hudson's guides have been incredibly helpful in helping me get accustomed to this new framework and language. A good start if you're looking to learn SwiftUI would be this tutorial: iDine
Color Hunt is really great if you cannot design for the life of you (like me). Aesthetically pleasing color schemes from more design-gifted people are posted there for your styling needs.
Of course where would I be without this site. Notable threads that REALLY helped me print to a bluetooth printer from an iOS device:
- Characteristic and Print Buffer - Kudos to Giorgio for laying out which characteristics were meant for printing and pointing out the print buffer.
- BLEConnection - information from here provided me with a really good understanding of how bluetooth connections work in SwiftUI.
Kudos to jrendel for writing this wrapper to significantly simplify Keychain wrapper. Implementing the app passcode would be significantly more complicated without this.
Although this guide is not specifically for SwiftUI, I was still able to learn how connecting to a BLE device should work and adapt it to the new framework by Apple.