Skip to Content
Technical Articles
Author's profile photo Kevin Muessig

The End2End Journey: Advocates App with SAP BTP SDK for iOS

The SAP BTP SDK for iOS

In the last blog post I’ve showed you a quick and easy way to build a basic Advocates App using the No-Code/Low-Code platform AppGyver. AppGyver gives you an easy tool to build your basic business app with an accessible approach to building UI.

With the SAP BTP SDK for iOS you can build an Advocates App and any other business app you might think of. The SAP provided SDK gives you a way to implement Swift native apps for the different Apple platforms (iOS, iPadOS, MacOS, tvOS). The SDK provides you with frameworks not only for UI elements but also for security, connection to SAP BTP through SAP Mobile Service, OData support for v2 and v4, Offline capabilities for OData v2, exchange for CoreML models without the need for updating the app version and much more.

For more information visit the SAP Developer Center – SAP BTP SDK for iOS

So how is this different than just using AppGyver to build your app. To answer this in a short manner: The technology depends on your Use Case. Of course there are different factors as well like budget, development skills and so on but in a perfect world where you can choose the technology freely I would say the Use Case will decide for what technology you go for.

Use Cases with simple tasks like displaying data, changing data or no need for advanced device capabilities you can go for a technology like AppGyver. If you need an advanced business app using offline capabilities, processing larger amounts of data, using a wide spectrum of the devices capabilities like on-device machine learning, AR, sensors and also have a platform conform UX than I would go with the native frameworks either iOS or Android.

With the development of Swift native apps you have the choice between two different UI frameworks: UIKit and SwiftUI.

Both, UIKit and SwiftUI are native Apple frameworks with Swift as their programming language. The SAP BTP SDK for iOS provides you with a sophisticated and mature UIKit based framework called SAPFiori. This framework provides you with more than 100 native UI controls, options for theming, complex controls for advanced UI flows, complete user onboarding and more.

SAP is currently working on adapting the UIKit based framework to SwiftUI but has it available for testing in a non-production environment on the official GitHub Open Source repository. We will talk about the SwiftUI based development in the next blog post.

For those of you who have worked with the SAP BTP SDK for iOS for a while now or already completed some of the tutorial missions on the SAP Developer Center should have a basic idea on how the development of a true native app would look like. Nevertheless, I will show how you how to use the SAP BTP SDK for iOS Assistant to generate a native and Swift based iOS app which is ready to run on the available Apple platforms. The app will have a complete data layer created for us, with connection to the Advocates OData service, Push Notification enabled and much more with just a snap of your finger. I will also show you how to enhance this app to look similar to the Advocates AppGyver app.

Let’s get Started!

SAP Mobile Services

In order to get started with the SDK you should understand the architectural role of SAP Mobile Services. Mobile Services is a Service available on SAP BTP which allows you to manage your app, provide data and to consume information for and from a native app on iOS or Android. Using Mobile Services allows you to push onboarding information to your app, handle authentication, routing to the data service, pushing CoreML models to your device, supporting your users through extensive logging capabilities, enabling Offline OData through offline synchronisation and more. In order to connect your native app with SAP Mobile Services you don’t have to do much except of using the SAP BTP SDK for iOS Assistant. The Assistant will create the needed code for you in an automatic manner after defining which features are needed, even if you have a legacy app creating the connection to SAP Mobile Services is fairly easy using the Discovery Service capabilities.

To learn more about all the available features within SAP Mobile Services you can go here.

SAP BTP SDK for iOS Assistant

The SAP BTP SDK for iOS Assistant is a native Swift based Mac app which comes with the SDK download. This companion app can be used to generate a basic iOS app out of a mobile app definition within SAP Mobile Services. The beauty here is that you have one configuration in the SAP BTP but can use this for multiple mobile apps like iOS, Android, MDK (Mobile Development Kit), and SAP Mobile Cards. The iOS Assistant will pull all needed information for user onboarding, authentication and data service endpoint through the connection to SAP Mobile Services. While generating the app for you, the iOS Assistant will create the needed code for all this tasks for you with corresponding configuration files AppParameters and ConfigurationProvider.

ConfigurationProvider

ConfigurationProvider

AppParameters

AppParameters

 

The configuration files contain the authentication information as well as the configuration for the discovery service to function properly. With this and the generated onboarding process, user onboarding is available out of box. Complete user management can be done through SAP Mobile Services as well.

The true power with the iOS Assistant lies in its capabilities to generate a whole data service layer out of a Metadata document of your OData service. The assistant will fetch the metadata document from the service endpoint and parse it into Swift native proxy classes representing the entities of your service. On top of these proxy classes you get a complete data service API generated. With this approach you will cut your development time in almost half as you don’t have to take care of creating the backend connection by yourself.

So to summarise what does the iOS Assistant give you to shorten your development time by almost half:

  • Swift native proxy classes representing the entities of your service
  • Data Service API which allows direct interaction with the backend service
  • Authentication against SAP Mobile Services as well as your backend
  • User Management through SAP Mobile Services
  • Complete and customisable User Onboarding flow through Discovery Service
  • OData offline synchronisation with help of SAP Mobile Services
  • Master-Detail Views in UIKit with full CRUD functionality in place
  • Code for Push Notifications

The iOS Assistant is an amazing tool for you as a developer to shorten your development time and make it easier to get started with your next-gen business apps!

Build the Advocates App with UIKit

In this section I want to give you a quick overview of my process of building a business app. Here I will show how to build the Advocates App with the UIKit based approach of the SAP BTP SDK for iOS.

I already have connected the iOS Assistant to Mobile Services and can now begin to create a brand new app. What is great here is that I can create even the cloud configuration from within the iOS Assistant.

To create not only the app but also the needed Mobile Services configuration from scratch you can use one of the workflows within the iOS Assistant to do so.

The process of creating all you need from scratch is containing out of 7 simple steps. The iOS Assistant will guide you through the process so making mistakes or do misconfiguration gets avoided.

1. Select an Account

First select the account from where you want to start the process. This is necessary as you might have multiple accounts which might represent your demo, staging and productive account.

2. Create the Cloud Application configuration

The second step will let you create the previously mentioned cloud application configuration which lives in SAP Mobile Services. This configuration is responsible for making not only the connection to the backend through the destination service of SAP BTP but also allows you to fully control access of your app, resource management, and the usage of other great services.

For a quick overview of the available features you can watch the SAP Mobile Services: Features video on YouTube.

The authentication field you see here is not the authentication against your backend service but for your SAP Mobile Services account.

3. Destinations

Destinations within the mobile space work the same way as everywhere within SAP BTP. SAP Mobile Services uses the destination service of SAP BTP and allows you to define the backend endpoint as well as its authentication right here in the iOS Assistant.

Based on this destination the iOS Assistant will then try to fetch the metadata document for the data service layer during the project generation process.

4. Features

The features step will allow you to define which SAP Mobile Services features you want to use within your app. There are additional features available through the Mobile Services cockpit after the creation process has finished. Here you will only get displayed the features which directly will generate code within your native app like the OData Offline, Push Notifications, Logging, etc.

These features are typically needed in a productive app which you want to ship to your customers. Enabling these will generate the needed code directly into your app and you don’t have to do anything really to make them work, this you will get out of the box!

5. Xcode Project

Now that we finished the Cloud Configuration process, you can create the Client Configuration. This means creating the actual Xcode project!

The set properties and fields will directly get reflected in your Xcode project. Make sure you set the values in a meaningful matter as these will also be visible, after the release process of your app, in the App Store. No worries, you can always change these values within the Xcode project at a later point but it makes sense to directly set them right.

What you can see here is a checkbox indicating the Mac Catalyst feature. Because the newer macOS versions (Catalina and newer) allows you to run Swift based apps on the OS, you can also run your business apps build with the SAP BTP SDK for iOS directly on your macOS system. Checking the box here will set the project up in the correct way for having this feature out of the box.

6. Proxy Classes

The proxy classes step is optional as you can make additional configurations to the proxy generation process. This you can leave at default most of the times, if you need to change anything here it would be the service name or additional configurations for the treatment of the generation process.

As I’ve said you can leave this at default for most of the cases.

7. UI Configuration

The last and final step is to define what UI elements the iOS Assistant is supposed to generate for you.

You can choose between letting the iOS Assistant generate the onboarding flow + Master/Detail screens or just either of these. My recommendation would be to generate both if you are new to the SAP BTP SDK for iOS as it will generate not only some basic screens for you but also all the code on how to call the data service layer from within the app. If you are more experienced or are working on a productive app you can just generate the onboarding process as this includes the onboarding flow, usage of discovery service and the authentication against the backend.

After you’ve made your choices you can finally click on Finish to let the iOS Assistant do its magic. What happens now is that the iOS Assistant will use the Xcode CLI to create the Xcode project stub depending on your configuration. The metadata document gets fetched from its endpoint and being parsed into the proxy classes and data service API within your app. Depending on your configuration the iOS Assistant will generate the UI and onboarding flow for you.

The Xcode project should automatically open up after the process has finished.

You can go ahead and run the app directly if you have chosen to generate the Master / Detail Screens.

Changing the generated App to become the Advocates App

Now that the app project is generated and a great start for the Advocates App is created just some minor changes are necessary to proceed with replacing the generated UI with your own.

  1. Change the Main.storyboard and delete the generated Views
  2. Use the ApplicationUIManager.swift class to instantiate the Initial View Controller

    func showApplicationScreen(completionHandler: @escaping (Error?) -> Void) {
            // Check if an application screen has already been presented
            guard self.isSplashPresented else {
                completionHandler(nil)
                return
            }
    
            // Restore the saved application screen or create a new one
            let appViewController: UIViewController
            if let savedViewController = self._savedApplicationRootViewController {
                appViewController = savedViewController
            } else {
                let navigationController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateInitialViewController() as! UINavigationController
                appViewController = navigationController
            }
            self.window.rootViewController = appViewController
            self._onboardingSplashViewController = nil
            self._savedApplicationRootViewController = nil
            self._coveringViewController = nil
    
            completionHandler(nil)
        }
  3. Build your UI the UIKit way

If you’re interested in learning how to build such an app you can use the following resources:

  • https://developers.sap.com/mission.sdk-ios-one-code-line.html
  • https://developers.sap.com/mission.sdk-ios-image-classifier.html

And with that you have the Advocates App up and running.

Next time we will talk about in how far we can implement the Advocates App with SwiftUI and still use the SAP BTP SDK for iOS OData Data Service Layer!

As Always, Keep Coding!

Assigned tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.