Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member183924
Active Participant
0 Kudos
This is an end-to-end introduction, how to run a swift application on Cloud Foundry stack within SAP Cloud Platform.

 

Steps



  1. Prerequisites

  2. Clone Sample App

  3. Push Application to SCP - CloudFroundry

  4. Modify iOS app to connect to CF instance



Prerequisites



- CocoaPods: https://guides.cocoapods.org/using/getting-started.html (I recommend to install it in user directory via following bash command:


gem install cocoapods --user-install
echo 'export PATH=$PATH:$HOME/.gem/ruby/2.3.0/bin'



Clone Sample App


IBM has provided a backend sample app for the popular iOS App "FoodTracker" by Apple.



You can now walk through of the tutorial or directly check out the branch "CompletedFoodTracker".



Push Application to SCP - CloudFroundry 



Once the server application successfully runs locally you can push it to you Cloud Foundry instance.



Unfortunately, the swift-buildpack in the `manifest.yml` file points to a service, which doesn't exist in SCP Cloud Foundry environment, yet. Therefor, we have to change the buildpack to the github repo provided by IBM. It seems that the CF community buildpack is no longer maintained.



Which buildpacks are available, can be found out with following command: cf marketplace



Modify file .swift-version of the FoodTracker server to meet the version in the buildpack:


4.0.3




Create the file Procfile in Foodserver folder, with following content, that CF knows what should be started after an successful upload:


web: FoodServer




Now the server application can be pushed to


cf api https://api.cf.eu10.hana.ondemand.com
cf login
cf push foodserver​


In the output you'll see for the routes output, under which URL your app is deployed and reachable.

It's something like: https://foodserver-xxxxxx-yyyyyy.cfapps.eu10.hana.ondemand.com


The route name is created dynamically, see manifest.yml file...


Modify iOS app to connect to CF instance


To communicate with FoodTracker-server via iOS app just replace the baseURL, used for creation the KituraKit class:



guard let client = KituraKit(baseURL: "https://foodserver-xxxxxxx-yyyyyyy.cfapps.eu10.hana.ondemand.com")





In a next blog I'll show you how to extend this server side Swift app with a real database.
2 Comments