Create Xcode Project with SAP BTP SDK for iOS
Prerequisites
- Tutorials: Get a Free Trial Account on SAP BTP and Enable SAP Mobile Services
- Development environment: Apple Mac running macOS Catalina or higher with Xcode 12 or higher
- SAP BTP SDK for iOS: Version 6.0
- How to create a connection in the SAP BTP SDK Assistant for iOS
- How to generate an app with the SAP BTP SDK Assistant for iOS
- Step 1
The SAP BTP SDK for iOS is designed to work seamlessly with a set of services that are optimised for communication with mobile devices, known collectively as SAP Mobile Services. These include not only data services, but also features like analytics, push notifications, and app configuration. Before creating your first app, you’ll need to ensure that Mobile Services are enabled for your trial account.
Log in to complete tutorial - Step 2
With your account created, you can now use the Assistant to create cloud application configurations on the Mobile Services back end, create destinations pointing to data service endpoints, and generate Xcode projects with a built-in data service layer to access the backend via Swift.
For the remainder of this tutorial, you will use the Assistant to generate an Xcode project that accesses a sample backend hosted on the SAP BTP, Cloud Foundry runtime, then replace the generated user interface with your own, and finally add the code necessary to integrate a Core ML machine learning model to classify product images.
Let’s get started by creating a cloud application definition on Mobile Services connecting to a service named Mobile Sample OData ESPM.
Go to your SAP Mobile Services Trial account in your web browser.
You will create a new native application cloud configuration on Mobile Services. To do so click on Native/Hybrid on the left-hand side and then on New.
In the upcoming dialogue enter the following values and click on Next.
Field Name Value ID com.example
Name SalesAssistant
For the next step you can define which features you want to use within your application cloud configuration. Just make sure to check the Mobile Sample OData ESPM and click on Finish.
After the creation process is done you will be automatically put on the
SalesAssistant
application detail page.On that page you can see all the details for your application as well as all assigned features with the option to navigate into each of these for configuration and further details.
Click on Mobile Sample OData ESPM on the right-hand side to get more details about the sample OData service.
In there you can see an overview about the existing properties for each Entity Set like in this case Customers. You can also see the Root URL as well as a quick link to the Metadata URL. This can be helpful to understand your OData service better before you start with the mobile app.
Log in to complete tutorial - Step 3
Open up the SAP BTP SDK Assistant for iOS and click Create new.
Next, click on Reuse Existing Application to start the workflow of using the just created native cloud application configuration from the last step. Choosing this workflow gives you the ability to customize many aspects of the back end connection and select various features for the generated Xcode project.
In step 1 of this workflow, you should see listed the Mobile Services account you created earlier in this tutorial.
The account should be pre-selected so you can simply click Next to continue.
In step 2 labeled Cloud Application, you will reuse the native cloud application configuration for your iOS app. This configuration contains a destination, some sort of reverse proxy, to connect to the sample service backend.
Select the
SalesAssistant
in the displayed list and click on Next.For step 3, labeled Xcode Project, enter these values for the following fields:
Field Value Product Name SalesAssistant
Organization Name Your organization name Organization Identifier com.example
For your real apps, please select the organization name and identifier wisely. This will be your bundle identifier, which will be used to identify your app. No worries, you can change the bundle identifier in the Xcode project.
Click Next.
For step 4, labeled Proxy Classes, you should see the sample service name
com.sap.edm.sampleservice.v2
that you selected in step 2 of the workflow.Click Next.
The last and final step is UI configuration. Here you can choose from a number of iOS app types the Assistant can generate. For this tutorial, you want a
Splitscreen
that includes the on-boarding flow, so make sure the Master / Detail Screens for all Destinations and Onboarding radio button are selected.Click Finish.
The SAP BTP SDK Assistant for iOS will now create the cloud application on Mobile Services, pull the metadata document of the OData service and generate an Xcode project, including the on-boarding flow and all the necessary proxy classes and a convenience data service API.
Log in to complete tutorial - Step 4
After clicking Finish, the Assistant will generate an Xcode project, save it to disk, and open the project in Xcode.
-
To compile and open your app in the iOS Simulator, click the run button in the top-left corner of the Xcode toolbar or choose Run from the Xcode Project menu. You can also change the simulated device at any time over the active scheme dropdown next to your app scheme.
The iOS Simulator should launch, initialize iOS, then run your app. The first screen you’ll see is the start of the generated on-boarding flow. It’s important to know that the generated on-boarding flow is simply the default experience and can be easily modified to fit your requirements.
Click Start.
If you’re interested in the different on-boarding variants you can take a look at the design guidelines:
* Fiori for iOS Design Guidelines - Single-user Onboarding.
* Fiori for iOS Design Guidelines - Multi-user Onboarding -
Next, your app will connect to the SAP identity provider triggering an authentication prompt for your SAP BTP account id and password.
Please enter the needed information and click Log on.
You could also define your own IDP on the cloud side if you don’t want to use the SAP IDP.
-
The next screen shows an example Data Privacy disclosure prompt which allows you to include data privacy and consent text that complies with the EU General Data Protection Regulation (GDPR) for example.
Click Allow to continue with the flow. Clicking Deny will cause the app to go back to the initial screen of the on-boarding flow.
-
After the Data privacy disclosure you will be provided with a consent form for Usage Data Collection which is also an optional step for you to configure.
Click Allow to continue with the flow. Clicking Deny will cause the app to go back to the initial screen of the on-boarding flow.
-
You’ll be present the passcode screen. This screen is optional when building your own app however, requiring a passcode can provide an additional layer of security for accessing sensitive data like customer information, sales numbers, etc.
Enter a passcode containing 8 characters. For this tutorial series it’s sufficient to just enter a passcode of
12345678
.Passcode policies are managed via Mobile Services and can contain configurations that define the password complexity, how many failed attempts are allowed before the app locks, etc.
-
Before you click Next, select on
Features > FaceID > Enrolled
.
This will configure the simulator to automatically useFaceID
orTouchID
to unlock the app instead of asking you for a passcode every time it’s run.After you’ve enrolled in
TouchID
orFaceID
(depending on the simulator you’re using) , click Next.Re-enter your passcode and click Done.
Now that you’ve enrolled in
TouchID
orFaceID
, a screen will be added to the on-boarding flow asking you to authorize the app to use Apple’s native security feature.Click Enable to continue.
Congratulations, you’ve successfully on-boarded into your app! You should see a table view containing all the entities of our sample OData service allowing you to edit existing records, insert your own, or delete records altogether.
Click on an entity to see its records.
What do you have to do to not have to enter the app passcode every time in simulator.
Log in to complete tutorial -