This is an end-to-end introduction, how to run a swift application on Cloud Foundry stack within SAP Cloud Platform.
Steps
- Prerequisites
- Clone Sample App
- Push Application to SCP - CloudFroundry
- Modify iOS app to connect to CF instance
Prerequisites
gem install cocoapods --user-install
echo 'export PATH=$PATH:$HOME/.gem/ruby/2.3.0/bin'
Clone Sample App
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:
Create the file Procfile in Foodserver folder, with following content, that CF knows what should be started after an successful upload:
Now the server application can be pushed to
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.