Let me start with the introduction of Mobile App Community. Mobile App Community is an internal community inside Rakuten Commerce TECH, which consists of representative engineering leads from >20 mobile app products. Across borders of organizations, we are sharing Mobile App related TECH topics, best practices and challenges for each product. Here, AltSwiftUI is an open source project developed by one of the community members.
SwiftUI, introduced by Apple in 2019, allows developers to create apps with declarative UI programming and state management, which greatly helps to improve development speed and quality. However, the framework is locked at the iOS 13 SDK, and every new improvement iteration to this new framework will push up this restriction to the latest SDK (iOS 14, and so on).
AltSwiftUI is an open source UI framework for iOS that mimics SwiftUI’s interface, introducing a single OS baseline at iOS 11 and greater flexibility because of its open source nature.
Starting to use AltSwiftUI is pretty straightforward, just import it through Cocoa pods or Swift Package Manager. If you are familiar with SwiftUI syntax, then you are good to go.
For more info see: https://github.com/rakutentech/AltSwiftUI
How does the code look?
What else does AltSwiftUI offer?
Even though AltSwiftUI has a very similar interface and features compared to SwiftUI, because we needed more features and capabilities than originally offered in order to develop iOS apps, AltSwiftUI introduces extra functionalities.
For example, we needed deeper integrations with List and ScrollView interactions, so there are methods like ScrollView.scrollOffset and List.onDragStarted. There are also multiple small additions to some of the views and modifiers, and this list will keep growing in the future. To identify these features, you can read the source documentation during development or at https://altswiftui.com.
AltSwiftUI in Rakuten Travel
AltSwiftUI’s development started at the end of 2019, with the main purpose of taking on new projects while renewing the way we design software, improve the speed and quality of our development, and be more futureproof. During this journey, we tackled multiple challenges by comparing what SwiftUI originally offered with what our app needed, and the open source nature of this framework allowed us to improve it by adding features that would allow us to meet our app expectations. Rakuten Travel Premium Club is one of our published apps built with AltSwiftUI.
One of the pillars that gave us a strong advantage in terms of design and development, is the ability to simplify our app’s architecture. In contrast to using design patterns such as MVVM or VIPER, which usually tend to increase the number of things a developer needs to worry about, we could transition to a MV (model view) design with AltSwiftUI at its core.
The core principle of this MV design is that developers should focus more on what they want to build, rather than how. By clearly delimiting what is part of the UI (view layer) and what is part of our business logic/data (model layer), we were able to also easily visualize our tasks and improve development efficiency.
The view layer consists of components that interact with the user. This includes the actual view structure, its local state, navigation, gestures, animations, and so on. We define all of this in a single layer by the use of declarative programming.
The model layer consists of operations that retrieve, process and store data that are part of our business domain. At the same time, it exposes this data to the view layer as transparently as possible for a simple and smooth integration.
The framework’s ability to integrate view state with data, including automatic updates, is what allows us to remove intermediate layers that introduce complexity and would often be the cause of bugs. Instead, the framework handles these intermediate layers without needing to add extra codes.
It’s hard to tell what will happen in some years from now. By working with the same design philosophy that accompanies the emerging SwiftUI framework and also an extremely similar code structure, we improve our changes for any future transition to be less costly and smoother.
AltSwiftUI’s future
Following the project’s roadmap, our goal is for the framework to get new components as they are released in SwiftUI, as well as keep getting new extra features for the better quality of life. Using your own hands to extend it to your needs is also possible!