Skip to Content
Product Information

SAP BTP SDK for iOS & CAP with OData V4 support

In the past the SAP BTP SDK for iOS didn’t support OData V4 which was problematic when trying to connect your iOS app to a Cloud Application Programming Model service. CAP by default only supports OData V4, you had and still have to use the SAP OData V2 proxy adapter if you want to expose your CAP service using the OData V2 protocol version.

With the version of the SAP BTP SDK for iOS 5.1, released back in March 2021, the OData  V4 support got introduced.

Now you can simply use the SAP BTP SDK for iOS Assistant to generate an app for OData V4, you can try this out by using the SAP Sample Service available over SAP Mobile Services.

 

For you as Developer not much has changed except of being able to use the power of OData V4 inside your iOS apps now. The proxy class generation is still the same as well as the consumption of the generated data service layer.

Connecting to a CAP Service in a Nutshell

If we take a CAP service created by you through the help of a tutorial (Go here) or with an existing project you can easily connect to it through your iOS app using SAP Mobile Services and the destination feature.

There are two ways to actually generate the data service for your app:

  1. Create a new project with the SAP BTP SDK for iOS AssistantAs shown in the screenshot above you can use the iOS Assistant to add or select an existing destination pointing to an OData V4 service like a CAP service.
  2. Use the Command Line tool for generating the proxy classes directly out of a Metadata Document.With the iOS Assistant you can directly install the CLI tool.
    From there open your Terminal or any other CLI you’ve installed and use the following command to let the proxy class generator do its job.

    sapcpsdk-proxygenerator -m <path to: MyMetadata.xml> -s <MyServiceName> -cp <Generated Proxy Class Prefix> -d <Generated Proxy Destination>​

    Flags:

    -m : Metadata document on your local filesystem
    -s  : The service name used as dataservice name in your Xcode project
    -cp: Generated Proxy Class prefix
    -d  : The destination on your local filesystem for the generated classed to be put in

    This command will generate a complete dataservice layer for you to be used within your already existing app.

That is all you have to do for your OData V4 service to be consumed by the SDK.

For more information read the official SAPOData API reference or watch the SAP Tech Bytes video to this Blog Post on the official SAP Developers YouTube channel.

https://youtu.be/VLHNgeAw8Zg

With that Keep Coding! And stay Healthy!

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