I wrote my first line of code in 1983. I was 8 years old. The machine was a shining Commodore VIC-20. I started with BASIC and a few years later I was experimenting with Logo.
Fast-forward to 2001. I was graduating in industrial engineering: my thesis being a business game for which I did spend several nights on a Linux computer, coding servlets in Java while developing a MySQL database. For several years afterwords, that business game has been played by students approaching company management and competitive markets.
As for myself, during the last 15 years I have been too much absorbed to develop my professional career as a manger and too much involved to develop my relationships with the opposite sex into a marriage, and I did end-up forgetting everything I once learned about the creative pleasures of coding.
In the last six months I’ve started to move my first steps in the stock market, with one company in my portfolio being Apple. I’ve started to follow it more closely, thanks to the Apple Stocks App on the iPhone, and through the Apple Events App on the Apple TV. When last June I was watching at the WWDC16 Keynote, I was at first fascinated, and by the end of the closing video I was smiling: I started to remember I was used to like to code.
Last Juy I was on a holiday with my family in Croatia. One afternoon the kids were sleeping and I was enjoying my timeframe of freedom surfing the web. My mind was still looking backwards at the WWDC16 and at the just announced Swift Playgrounds iPad App. Digging for some more information I landed on the App Development with Swift iBook Preview.
That very afternoon I read the first chapter and experimented for the first time with a Swift Playground. At that point my strategy was to enjoy the few preview chapters and then to wait for this fall, when both the App and the full iBook will be released. I was postponing to the end of this training path the challenge to try to write my very first App: in the last few years I was considering several ideas for some new App’s, and now it could have come the moment to try to make them a reality. That sounded a strategy, at least.
But last week I did reach the 4th & last chapter of the iBook Preview, and that scenario went through a sudden change.
As a Scrum practitioner, I always like to set stretch goals and to jump into new challenges. And I expect from myself, as from everybody involved, daily progresses materializing into weekly results. To put it in short, I redefined my strategy as follows: what-if I can prove myself that I can develop my very first App within one week, to achieve a first result which I can “touch with my fingertips”, and then I wait for the release of the full iBook to work an a more ambitious project? Couldn’t it be a good mix of fun, excitement, challenge and reward?
The idea came from that 4th & last chapter of the iBook Preview (an App which is displaying a photo) combined with the opportunity to work on the promotion of a book at a local event in my city, which was set for next September. I was fascinated by the challenge to find the right way to modify the example found in the iBook into a sort of digital/minimalist advent calendar for the local book presentation event. Instead of a single image, the logic was to display a different page of the book for each single day during the last month before the presentation date, with some special cases for people accessing the App too early, or the very same date of the event, or afterwords. Furthermore I wanted to give the possibility to share the book page on Facebook and to add the book presentation event date on the local iPhone calendar. Last but not least, the access to the App after the presentation of the book should redirect the user to the Italian online bookstore where to buy the book.
The first thing you need to know if you want to develop an iOS App (aka an App to be run on an iPhone or an iPad) is that you need a Mac (in my case I am using a MacBook) to run the free IDE Xcode (aka the software you will use to write your App, and which you will download on your Mac from the Mac App Store — no iPad version so far) where you will write your App, in my case in Swift (the programming language specifically developed by Apple). The bottom line is that Apple provides you all the software, and it’s free, but you need to buy their hardware. No other way.
The second thing you need to know is that to distribute your iOS App to other people, you will need to go through the App Store, which is the standard way all the iPhone and iPad owners worldwide find and install any App on their devices. To do so, you need to enroll (aka join) the Apple Development Program. Basically you pay a subscription fee of $99 per year, plus you will have to leave to Apple the 30% of your earnings, if any.
In short: you need a Mac plus a $99 yearly subscription fee plus Xcode (this is downloaded freely with your Mac from the Mac App Store).
I strongly suggest to start with the App Development with Swift iBooks Preview, which — at least in the few chapters available so far — is extremly clear and well done. If you are not in a hurry, it would be definetly a good idea to wait for next fall when the full iBook will be released. Another useful starting point is Start Developing iOS Apps (Swift), which is freely available online.
With these two tools I have been able to assemble a first very simple App, and I’ve been paid back by my first two WOW! moments: when I understood I have on my Mac (Xcode) a fully working free simulator for all iOS platforms (from the dated iPhone 4 up to the latest iPad Pro) and when I’ve been able to transfer my simple App to my iPhone and bring it with me wherever I went.
So far so good, but I was following literrally a set of step-by-step instructions. It was great the DYI feeling, but the level of challenge was quite low. Things went through a huge change when I found myself suddenly alone willing to manipulate this simple program (show a specific image) into my “digital advent calendar” for the promotion of the book presentation event.
The first challenge has been where and how to write some code in order to let the App to decide which image was to be shown, in my case based on the actual date. Digging into the example contained in Start Developing iOS Apps (Swift) I have been able to properly connect (technically through an outlet) the image element of the graphical interface (technically an Image View in the View Controller Scene) to the code (technically the ViewController.swift file). I was ready to write an if-then clause to associate different pages of the book (aka screenshots) to different dates.
The second challenge has been to find out how to interrogate the current date (hint: you need to use an object from the class NSDate) and how to “manage it”. I named the images of the selected pages of the book with names like “MMDD”, for example the image named “0902” was supposed to be shown on Sep-2nd. The problem was that my current date was something like “Aug 6, 2016, 9:31 PM” which converted into a text (aka string) was something like “2016–08–06 19:31:03 +0000”. How to extract that “0806” which I needed to load my book page? I was looking for a sort of “substring” function and googled everywhere, but failed. That night I finally quit and went to sleep promising myself to give up and wait for the release of the full App Development with Swift iBook.
Luckyly a few hours of decent sleep can still reset my mood and restore my mental energy. The day after I was ready to start over again and to look for a solution to my troubles. Finally I managed to correctly use the string indeces as describe in the official documentation of The Swift Programming Language (Swift 2.2): String and Characters.
Now I was able to show an image based on the actual date. But when I tried to manually change the date of my iPhone… the image was not changing at all! Indeed time never stops… but how to tell to my App to never stop to check the time? I poundered on this issue for a couple of hours, till when the most simple idea hit my mind… let’s look for the source code of a chronometer App! I found my answer in Simple StopWatch app in Swift by Ravi Shankar (hint: you need to schedule a timer in a run loop using an object of the class NSTimer). I coded it and it worked. That was definetly another WOW! moment :)
In short: never give up! there is a huge supporting community out there, and if you focus on creative ways to approach and solve your problems, most probably you will be able to find a way out. Anyway is a good idea to familiarize with the The Swift Programming Language (Swift 2.2).
As mentioned, once you have a working App and you want to make it public, you need to upload it on the App Store. The first time it can be pretty tricky and you will need a guide. Luckily you are never alone out there, and my suggestion is for How to Submit An App to Apple: From No Account to App Store by Tony Dahbura.
In short: let AppIcon Generator create all the needed icons for you and follow a step-by-step guide such as How to Submit An App to Apple: From No Account to App Store.
The first complimentary function which I wanted to add to my App was the possibility to share the book page on Facebook. One more time I was searching for some specific guide on this issue, and here it is: Get Social With Swift — Posting to Facebook and Twitter by Andrew Bancroft (hint: you need to import the Social module and use its class SLComposeViewController).
The second complimentary function which I wanted to add to my App was the possibility to add an event to my calendar with the date and time of the book presentation. The solution was nearby: Creating Calendar Events with Event Kit and Swift, again by Andrew Bancroft. This taks is quite more complex than the previous one, but it can be managed (hint: you need to import the EventKit module and work with the EKEventStore class).
The last complimentary function was to redirect to the Italian bookstore website, opening a web link in Safari. That’s pretty easy (hint: you need the method sharedApplication() from the class UIApplication).
In short: for Facebook and Twitter read Get Social With Swift — Posting to Facebook and Twitter, for accessing the calendar read Creating Calendar Events with Event Kit and Swift, to open a web link the solution is “UIApplication.sharedApplication().openURL(url!)”.
And he went back to meet the fox.
“Goodbye,” he said.
“Goodbye,” said the fox. “And now here is my secret, a very simple secret: It is only with the heart that one can see rightly; what is essential is invisible to the eye.”
“What is essential is invisible to the eye,” the little prince repeated, so that he would be sure to remember.
“It is the time you have wasted for your rose that makes your rose so important.”
“It is the time I have wasted for my rose — “ said the little prince, so that he would be sure to remember.
“Men have forgotten this truth,” said the fox. “But you must not forget it. You become responsible, forever, for what you have tamed. You are responsible for your rose . . .”
“I am responsible for my rose,” the little prince repeated, so that he would be sure to remember.
Thanks to Apple and all Apple’s employees for having created the App Economy and for sustaining the “everyone can code” approach. Thanks to Andrew Bancroft for “sharing bits of what he is learning one byte at a time”. Thanks to Ravi Shankar because “in learning you will teach, and in teaching you will learn”. Thanks to Tony Dahbura for “helping folks realize the joy of custom apps to meet their needs”. Thanks to TweakNow for having simplified my life at an affordable price. Thanks to all the people out there sharing their knowledge to support with passion the developers’ community.
Here you can download my first App and here the Xcode source code
Create your free account to unlock your custom reading experience.