SAP Fiori Mentor app, as interactive documentation to discover and view live previews of all UI components, is pretty neat. As a designer or developer, you can easily change parameters and see the effect immediately.
But is it possible to get such preview functionality for your own UI-Kit based components built on top of SAP Cloud Platform SDK for iOS?
Yes 😃 🎉 ! This blog post will give you an example.
Xcode Previews was added in Xcode 11 and allow you to quickly preview the current state of your view. You might think that you need to use SwiftUI in production to make use of this feature but it’s not true.
Whether you’re working with a custom UIView or with a custom UIViewController, they both support previews in the new canvas.
In the example illustrated below, we are previewing a custom subclass of FUIObjectTableViewCell
Here is the example code
Side note: if you are interested in how SAP Cloud Platform SDK for iOS is adopting SwiftUI then have a look at the new open-source project https://github.com/SAP/cloud-sdk-ios-fiori. This project is meant to augment and in some cases replace the UIKit-based implementation contained in the SAPFiori framework. This project is in development, and should not yet be used productively.