Create custom iOS app with SDK Assistant

Create an Xcode project with SDK Assistant, remove all generated UI parts, and create a custom built UI instead.

You will learn

How to create an Xcode project with the SDK Assistant

How to alter the Xcode project by safely removing the generated UI components and storyboards in order to implement your own custom UI

To create a custom SAP Fiori for iOS user interface

To utilize the iOS EventKit framework to create iOS Reminders from within your app

Details

While the SDK Assistant provides a quick way of generating an Xcode project based on an OData service with a secure on-boarding flow, the generated storyboards and master-detail views are generally not what you want to end up with.

In this tutorial, you will create an SAP Fiori for iOS application. You start with an Xcode project generated with the SDK Assistant, but instead of using the generated master-detail view, you will delete all generated views, view controllers and storyboards. Instead, you will create a custom UI.

The app will use the Sample ESPM OData service from SAP Cloud Platform mobile service for development and operations, and is capable of adding customer call-back reminders to the standard Reminders app.

Note: If you have already configured the SAP Cloud Platform SDK for iOS Assistant, you can skip this step and proceed with “Step 2 - Run the SAP Cloud Platform SDK for iOS Assistant”.

.

This step provides simplified steps to configure the SAP Cloud Platform SDK for iOS Assistant application using the SAP Cloud Platform mobile service for development and operations cockpit.

Log on to your SAP Cloud Platform trial account at https://account.hanatrial.ondemand.com/ and once logged in, navigate to Services. Scroll down to Mobile Services and click on the Development & Operations tile. In the Development & Operations - Overview page, click the Go to Service link to open a new window to SAP Cloud Platform mobile service for development and operations.

Alternatively, you can go directly to https://hcpms-<your_user_id>trial.dispatcher.hanatrial.ondemand.com/.

.

Once you’re logged in to SAP Cloud Platform mobile service for development and operations, click the Important Links tab in the lower left bottom. The Important Links section opens:

Locate the tile SAP Cloud Platform SDK for iOS Assistant and click the Importing URLs directly into Assistant link. You should now see the following pop-up:

Click the Open SAP Cloud Platform SDK for iOS Assistant button. The SAP Cloud Platform SDK for iOS Assistant application will start. The New Account settings dialog will open, and both Admin API URL and Admin UI URL parameters are pre-populated automatically:

Provide the following additional details:

Field

Value

Name

A descriptive name for the configuration, for instance SAP Cloud Platform Mobile Services

Authentication Type

Basic Authentication

User

Your trial account user

Password

Password for your trial account user

Click Add when finished. The account is now added to the SDK Assistant:

Note: If you went through “Step 1 - Configure SAP Cloud Platform SDK for iOS Assistant”, the SAP Cloud Platform SDK for iOS Assistant is already running and you may continue to “Step 3 - Create an Xcode Project”.

.

Double-click the SAP Cloud Platform SDK for iOS Assistant icon to start the application. If no applications have been generated previously, you will see the initial screen:

In the Optional Features page, the options to generate a Master-Detail Application, enable logging and log uploads, and enable remote notifications are checked. Since you have chosen to use the Sample OData service, the options are disabled.

After you have clicked Finish in the previous step, the SDK Assistant now loads the Sample OData service’s metadata. Based on this metadata, the OData proxy classes will be generated for the Xcode project, as well as the storyboards and view controllers for each entity set.

NB: If you have already 3 native applications defined in SAP Cloud Platform mobile service for development and operations, the SDK Assistant will give the following error:

In that case, log on to your SAP Cloud Platform mobile service for development and operations account at https://hcpms-<your_user_id>trial.dispatcher.hanatrial.ondemand.com/ and navigate to Mobile Applications > Native/Hybrid. Select one of the available application configurations and delete in order for the SDK Assistant to add the new application configuration.

After the SDK Assistant has finished, Xcode will launch and open the just generated ESPMReminders project.

The Main.storyboard shows split-view setup for the generated Master-Detail views.

Folder ESPMReminders/Onboarding contains logic for the user on-boarding, authentication and handling of pass-codes and Touch ID.

Folder Proxy Classes/public contains the OData proxy classes generated from the Sample OData service. File MyPrefixMyServiceClass.swift acts as a data service provider to gain access to the OData entities. The remaining MyPrefix<Entity>.swift classes give access to the various properties of the OData entities.

If you now click on one the collections, you navigate to a Master list with all available entities. Clicking on one of the listed entities navigates you to a Detail page which lists all the properties for the selected entity.

While this is nice if you need a data browser for your OData service, it’s not exactly what we want to achieve for our app.

Instead of start off with a list of all collections, we need a single list which loads all customers with their contact details. With a single tap, you should be able to call or email that customer, as well as add a reminder to contact him or her at a later time. This will be implemented in the final steps of this tutorial.

This ensures an SAPURLSession is created before the view is presented.

If you now build and run the app, after logging in you should see the following screen:

The app correctly displays the newly added Customers view. Unsurprisingly, no data is displayed yet since you haven’t yet created a controller class for the table view, so the data model isn’t yet bound to the UI. Also, you haven’t yet specified the particular control which should be used to display the data.

This will add the activity buttons for calling, emailing and creating a reminder (which will be implemented in the final steps)

To make the UI a bit more pleasing, you may consider adding a placeholder image for the contact cell:- On the web, search for person placeholder image and download a nice looking image.- Drag the file into your Xcode project’s Assets.xcassets folder and rename it to a unique name, for instance PersonPlaceholder.- Display the image as an image literal in the tableView(_:cellForRowAt:) method:

cell.detailImage = #imageLiteral(resourceName: "PersonPlaceholder")

.

If you now build and run the app, it looks and works a lot better:

If you would run this on a physical device, you should now be able to initiate a call to the bound number or start an email to the bound email address for the selected customer.

This will initialize the event store, and check for permissions to access your reminders. It then holds an array of available reminder lists, and finally it will call a not yet implemented method checkIfESPMReminderListExists() to check whether a custom reminder list ESPM already exists.

In order for your app to access your reminders, you must add an entry in the app’s Info.plist file: