In this Code Pattern, we will look at comparing downloading Atlantic Hurricane Season images from a traditional server (Wikipedia in this case) and Cloud Object Storage on an iPhone. The images are stored in Cloud Object Storage as objects in one Bucket and a Zip archive in another Bucket.
When the reader has completed this Code Pattern, they will understand how to:
- Create an iOS Swift application
- Incorporate Cloud Object Storage into a Swift application
- User interacts with the app to start a download of objects (images) from Cloud Object Storage.
- The app makes the necessary calls to Cloud Object Storage to get the access token, list of bucket objects, and download the objects (images).
- The images are downloaded and displayed on the app to the user.
- Clone the repo
- Install developer tools
- Install dependencies
- Create Cloud Object Storage Buckets
- Run in Xcode
1. Clone the repo
Cone the repo locally. In a terminal, run:
$ git clone https://github.com/IBM/swift-cloud-object-storage-example $ cd swift-cloud-object-storage-example
2. Install developer tools
Ensure you have the required developer tools installed from Apple:
- iOS 12.0+
- Xcode 10.0+
- Swift 4.0+
3. Install dependencies
You can install CocoaPods using the following command:
$ sudo gem install cocoapods
If the CocoaPods repository is not configured, run the following command (this may take a long time depending on your network connection and installation state):
$ pod setup
Podfile has been included in this repository. To download and install the required dependencies, run the following command from your project directory:
$ pod install
If you run into any issues during the pod install, it is recommended to run a pod update by using the following commands:
$ pod update
$ pod install
Finally, open the Xcode workspace:
4. Create Cloud Object Storage Buckets
- Provision the IBM Cloud Object Storage Service and follow the set of instructions for creating a Bucket.
- Upload the images in
atlantic_hurricane_seasons/imagesto a Bucket.
atlantic_hurrincane_seasons/zipto create the zip file. Then upload the zip file to a different Bucket.
- Follow these instructions for obtaining an API key and
- Include the public endpoint, Bucket names, API key, and
5. Run in Xcode
In Xcode, click Product > Run to start the iOS application. Choose which download type to use for downloading the images from the Picker View. The download history results are logged in the
This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.