Category: iPhone

iPhone

Podcast Episode 23 – Apple Pay, Apple Watch, and New iPhones – Oh My!

iPhone 6 and 6 PlusThis time, in Episode 23, I recap the September 2014 Apple Launch Event. During this event, Apple launched iPhone 6 and 6 Plus, along with Apple Pay and Apple Watch. I wasn’t really enthusiastic for this event going in because I don’t like big phones, I couldn’t care less about NFC payments, and I’m not excited about wearables. However, by the end of the presentation, I was excited for 2/4 of the products. Either I’m a sucker for marketing, or some of this stuff might actually be pretty good. Listen and find out which it is.


Links Mentioned in this Show:
The OK Go Story
Samsung’s Ad
Dimecasts (Link Removed)

Scarf Guy

Tommy the Scarf Guy

You can also subscribe to the podcast at any of these places:
iTunes Link RSS Feed

Thanks to all the people who listen, and a special thanks to those who have rated me. I really appreciate it.

The episodes have been archived. Click Here to see the archive page.

iOS

An Intro to CocoaPods

CocoaPods LogoIn today’s development landscape, dependency management is becoming an increasingly important problem to solve. As applications incorporate more and more external libraries (especially very active open source libraries), making sure that your application has the most up-to-date versions of those libraries becomes more tedious. Add in the necessity to make sure that every one of your dependencies has its dependencies met, you are definitely facing a headache.

If you come to Objective-C and iOS development from other languages, you might already be familiar with the solutions that those ecosystems provide. In .Net there is NuGet, Ruby has Gems, Node has NPM, etc. In Objective-C, the most popular dependency management system is CocoaPods.

CocoaPods is made with Ruby and you can get started with it with the version of Ruby that is on the Mac by default. All you have to do is type “sudo gem install cocoapods” (without quotes) in the terminal, enter your password, and you are off and running.

CocoaPods Install

The terminal will just sit and wait for awhile during the install. Unlike Homebrew, you don’t get any feedback during the installation. When it is finished, you will get a bunch of text for the change log for the version that you just installed and – if all went well – it will conclude with this message (the version could vary based on what is current when you are doing your install):

Successfully installed cocoapods-0.29.0
Parsing documentation for cocoapods-0.29.0
1 gem installed

After that, CocoaPods is ready to use.

For the first step, we need to have to make a new project (or use an existing project). Since we are starting fresh and new, I’ll just make a new project. I’m going to open Xcode and make a new project:

Xcode New Project

Then, I’m going to choose “Empty Application” and click next. (Note: you might see different options here based on what you configurations or installations you have on your machine.

Choose a Template

Then, we can fill out a little information about our application and click Next again. After that, choose somewhere to save it and finish up:

Set Project Options

After your project opens, go ahead and shut down Xcode. You are never going to intentionally directly open that .xcodeproj file again.

Open the terminal and navigate to the directory where you saved your project. First, we’ll create a podfile. A podfile is just a text file that keeps track of what dependencies you are taking and a list of the versions that you are willing to accept. We are just going to make a very simple podfile and take a dependency on AFNetworking, a very popular Objective-C networking client.

With your terminal active in your project’s directory, just type “touch Podfile”. That will make a podfile (no extension) in your directory. Then, you can edit that file in your favorite text editor. If you want to stay in the command line, you can type “vim Podfile” and then press i to go into insert mode. Then add the following text, followed by the key combination of Esc, then colon, then wq then . This will take you back to your terminal.

The file contents:

platform :ios, '7.0'

pod 'AFNetworking', '~> 2.0'

Here are those steps visually:

Touch Podfile

Podfile Contents

Type pod install and your pods will be installed and configured*
pod install

If you look at the project directory in Finder, you will now see that files and folders have been added.

After the Pod Install

The file that you care the most about now is the .xcworkspace file. If you are familiar with .Net, the .xcworkspace file is like the .sln file and the .xcodeproj file is like the .csproj or .vbproj files. The way that CocoaPods works, it makes your Pods code its own project and your existing code stays its own project and the .xcworkspace encompasses them both. As I mentioned earlier, from now on, don’t open your .xcodeproj file, but instead have Xcode open the .xcworkspace.

I find it handy to go File -> Open Recent -> Clear Menu from the Xcode menu so that my .xcodeproj file is removed from recent files and I don’t accidentally open it. Then, I can either double click on the .xcworkspace or choose “Open Other…” from the Xcode launch screen.

Now that the workspace is launched, you can see that the CocoaPods have been added to your code. Now you are able to import the header files into your code files and use your imported libraries as if they had always been there.

Podified Workspace

It might seem like we did a lot of steps to get to this point, but that was only because we had to include the initial CocoaPods gem installation. From now on, you just need to add a completed Podfile to your project directory, run pod install and then use the workspace from then on.

If you are the kind of person who likes to watch to learn rather than just read, you can check out a FREE video available over at NSScreencast about CocoaPods. Happy Podding!

* If you have an error when you run pod install, check out this StackOverflow, it solved my issue caused by a bad update to Cocoapods.

iPhone

Best Nine Dollars a Month You’ll Ever Spend

I’ve been getting more and more into iOS programming recently. It is something that I’ve been doing more and more as a hobby, as well as landing a few paying consulting roles creating native iOS applications. I’ve kind of been “marinating” in iOS for some time, but about a year ago I started really getting serious and attempting to have an actual goal with regards to Objective-C and iOS.

One good FREE resource is the Introduction to iPhone series on TekPub with Ben Schierman. It was done a few years ago, and Rob Conery has now given it to the community. It is a little out of date, but you can’t beat the price and it will help you learn a few things.

I have a TekPub subscription, so from there I moved on to Show Me Objective-C, another Ben Schierman TekPub series. I really liked the way that Ben explained things, so I started doing a little cyber-stalking digging about him and I discovered his site over at NSScreencast.

Ben has some free videos there, as well. I downloaded and watched them all and learned a TON. His video about AFNetworking alone was worth the time. I noticed that he had a subscription package initially, but didn’t check back into it until I had watched all of the free videos. I’m glad I did. He offers full access to his videos (new ones weekly) for only $9.00 a month.

This is a BARGAIN!

I feel like – thanks to Ben – that I am an honest-to-goodness-real-life iPhone Developer now. I’m not scared of Xcode, I’m not mystified by Objective-C, nothing. With the videos he has to date, you can spend a weekend and gain an insane amount of confidence on the platform. I highly recommend it.

Errors

Fun With The iPhone – DFU Mode

I recently applied a firmware update to my iPhone and it broke. The phone wasn’t jailbroken and there was nothing shady about the dealing whatsoever. However, when I applied the 2.2.1 firmware, iTunes announced failure and my phone went into the revovery mode where it just shows the screen below.

iPhone Recovery Mode

I let iTunes attempt to recover my phone to no avail. I finally did some frantic Googling and came across a site called TheBigBoss.org, where I found a post about DFU Mode. I did what The Big Boss said and used the very strange shift+click* on the restore button in iTunes to allow me to choose what backup file went to my iPhone and finally was able to recover my phone.

* Note: Also from The Big Boss, “If you need to restore a specific version of firmware onto your device, rather than click restore, hold shift (PC) or option (MAC) and click restore. This will bring up a browse box where you can select the firmware you wish to program.”

I can’t believe that this had to be such a convoluted process, but I’m thankful to TheBigBoss.org website for all of the wealth of information it contained. Maybe if this blog can help one person deal with this problem just a little quicker than they would have otherwise, it is all worth it.