iOS Databases, Module 1, Lessons 1-2

A new day, a new course from CWC+.

Having covered the intense but general iOS Foundations and the head-scratchingly rewarding Design Course, I now move onto the iOS Database Course.

The introduction, and first and second lessons, introduce us to the need for databases and why the course focuses on Firebase. I’ve had some dealings with databases before, from the desktop-based Lotus Approach and, less so, Microsoft Access, onto MySQL & MariaDB, plus some flatfile database work, for my websites.

I guess I have a slight advantage in that this gives me an understanding of what databases are, and why they are needed, but I’m willing to bet that Firebase is nothing like MariaDB and the Swift code is nothing like the PHP code I’ve been using. Oh, wouldn’t it be nice if we didn’t keep reinventing the wheel?

We’re also introduced to CocoaPods which, at this early stage, I still don’t really understand. Having an oddball sounding name doesn’t really help. The website (un)helpfully describes itself as “CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects”. This doesn’t really make it all that much clearer, so I’m going with it being the “middle man between the code we write and Firebase. If it becomes clearer than that, I’ll be sure to post about it!

In order to use CocoaPods, Lesson 2 takes us through installing it on our Mac. This requires some Terminal time and code which, for me, as someone who’s pretty familiar with the Linux command line, it isn’t as frightening as it might be for a newbie who’s only familiar with WIMP (Windows, Icons, Mouse, Pointer).

The installation steps are posted on the CocoaPods main page, re:

$ sudo gem install cocoapods

It gets a little trickier if you have a Mac M1, whereby you have to run Terminal via Rosetta to install additional requirements. These are laid out on this website.

  • Search for Terminal in Finder,
  • With all Terminal windows closed, right-click Terminal, select ‘Get Info’, and then check ‘Open using Rosetta’,
  • Open the Terminal and type sudo gem install ffi
  • Install cocoapods with sudo gem install cocoapods
  • Then uncheck the ‘Open using Rosetta’ option as before.

The lesson continues with steps to pod init (to create a Podfile in the current directory), how to add a pod (by adding a line to the Podfile), and then to ensure that the Xcode project is only opened using the .xcworkspace file and not the usual .xcodeproj file (only the former will include the cocoapod dependency). At this point we haven’t started a project, so I don’t know if we’re supposed to be doing what Chris is talking us through or not. It’s not likely that we’ll remember it.

The ‘challenge’ for Lesson 2 is to check if your Mac has Cocoapods installed and, if not, to install it. This bit I did follow through when Chris did it so I know this is already done.

For reference:

$ pod --version
1.11.3

After doing this yesterday afternoon, Xcode decided that it had an update to install, so I left it to it. We’re now on version 13.3.1 (13E500a). It didn’t take as long to update as it has in the past, but perhaps that was a more major update from Xcode 12 to Xcode 13.

This lesson finishes with a warning that Firebase is known to change things, and has done between the tutorial video being made and the present day. Just like Xcode, then! The wonders of technology.

With all that done, I think we’re ready for Lesson 3 : Creating a New Firebase Project. I think we’re now in the hands of Micah, not Chris, so let’s get hands-on with Firebase!