As iOS developers, CocoaPods are one of the favourite ways of leveraging dependencies within your projects.

At Keytree we have leveraged both CocoaPods and Carthage to inject dependencies to iOS projects, but with the new SAP Apple SDK, we wanted to use the frameworks with a dependency injection so I thought I would put together a guide on how you can achieve this.

Will Powell

Will Powell

Head of Innovation

Setting up your spec repository:

CocoaPods has a public repo of modules but also the ability to use private repos for your own use of libraries. As we wanted to use the SDK in our internal projects and the SDK is owned by SAP, I would advise as we have and set up a private repository. The repo is essentially a git repository, not the one where your project lives but one where you can list your framework details. Once you have a git repo all you need to do is run the following to setup the private repo:


Create your pod lib project:

Now you need to setup a project that will take the SAP SDK frameworks and distribute as a library. To do this run the following in command line:

pod lib create SAPFioriSDK

This method will then take you through the CocoaPod creation process and ask if you want to create an example project – I would advise yes as it’s a very easy way to test if everything is working. I would enter ‘None’ for the testing frameworks or view testing inclusion and then return. This approach should create a folder called SAPFioriSDK in the directory you’re in – and it should look like this:


Add Frameworks to pod lib project:

Now we need to insert the frameworks to the pod project and to do this download the SAP Cloud Platform SDK from SAP’s website. Then open the SAPFioriSDK subfolder and alongside the Classes and Assets directories create a new folder called Frameworks – and copy in all of the frameworks. So now it should look like:


Update podspec:

Now we have added the frameworks to the project space we will need to update the podspec to include them. Open the SAPFioriSDK.podspec file in your text editor of choice. Then you need to add the line:

s.vendored_frameworks = 'SAPFioriSDK/Frameworks/*.framework'

Between the do |s| and the end lines I would also advise updating the version to the SAP SDK version and update the name, iOS deployment target and description to the correct values.

Testing the pod:

This can be done within the example project if you navigate to the Example folder within the library you created and running:

pod update

Now you should see it install and then you can open the SAPFioriSDK.xcworkspace. Then go into you AppDelegate and type import SAPFiori at the top of the file and if it compiles and runs the pod is working and ready to go.

Pushing the lib to your private CocoaPod repository:

This is fairly straight forward to do. Open console and navigate to the root of the CocoaPod lib you created earlier. You should be in the same folder as your .podspec file. Now run the following:

pod repo push REPO_NAME SAPFioriSDK.podspec

Now you can include it in your projects using CocoaPods. To do this in your target project’s podfile include the private repo as a source by entering:

source ‘SOURCE_URL’

Then put the line in your target:

pod ‘SAPFioriSDK’

Then you can install the pod:

pod update

In summary, this provides a dependency injection method to encompass SAP Apple SDK into your projects easily and quickly. Plus, as the SDK is updated you will be able to pull in updates and version locking smoothly.

Leave a Reply