5 Killer Tools for iOS Developers

As a software developer, we are always looking for ways to maximize productivity while maintaining a strict guideline for quality code. As I have been developing and working with Xcode, I’ve discovered several tools that greatly enhance the developer experience of working with it. Even with the recent announcments of improved features and functionality in the upcoming version of XCode 6, the add-ons listed here are available to use today in your current projects.

1. Alcatraz

Alcatraz is a package manager for Xcode, which allows you to install additional plugins right inside of your IDE. In the past, Xcode hasn’t been very friendly with add-ons, but with the release of Xcode 5, they have eased up on what they allow developers to add-on to the IDE. Installing Alcatraz is as easy using the following command.

curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh

Once complete, it will ask you to restart Xcode. You will now see a “Package Manager” option after clicking “Window” -> “Package Manager” as shown in Figure 1.

Figure 1 : Alcatraz Package Manager has been installed.

Figure 1 : Alcatraz Package Manager has been installed.

Once launched, you have the option to select from a variety of Xcode plugins as shown in Figure 2 below:

Figure 2 : Current list of packages available to be installed.

Figure 2 : Current list of packages available to be installed.

One of my favorite plug-ins for XCode is called BBUDebuggerTuckAway, which allows you to dismiss the debug output window as you start typing for extra screen space. A sample of this is shown in Figure 3.

Figure 3 : Note that the debug output window is dismissed as I start typing.

Figure 3 : Note that the debug output window is dismissed as I start typing.

2. CocoaPods

After taking a look at a package manger for Xcode, you may be asking if a dependency manager exists? Absolutely! Cocoapods is a well-known dependency manager for Objective-C projects. There are literally thousands of libraries currently available. Sometimes programmers forget how useful it really is.

Cocoapods was built with Ruby and is easy to install using the default Ruby available on OS X. You can simply install it with the following command in your terminal window:

sudo gem install cocoapods

Once installed you should see the following in your terminal window (the actual version number depends on when you install it):

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

Go ahead and open Xcode and create a new “Single-View Application” and give it a name. I named mine TDNiOSApp. Navigate inside of the project you just created using the terminal and type the following command:

pod init

You will now have a Podfile and will need to edit it with the following command:

open -a Xcode Podfile

Let’s edit the file and use one of my favorite libraries called AFNetworking as shown in Figure 4.

Figure 4 : Your completed Podfile should look like this except for the project name.

Figure 4 : Your completed Podfile should look like this except for the project name.

Figure 4 : Your completed Podfile should look like this except for the project name.

It is worth noting that even though our project targets 7.1, we simply added 7.0 for the platform line. We also added an additional line to install the Pod and gave it the version number. In this case, we want the latest 2.x version.

Finally, save the file and type the following command to install the pod.

pod install

You will get a warning message that says the following:
From now on use TDNiOSApp.xcworkspace.

Go ahead and close your current project and launch the new workspace. You will see that we now have a “Pods” project along with AFNetworking already installed for us along with our original project as shown in Figure 5. We can now reference the new library as shown with the red arrow and hit CMD-B to build our project. It should build successfully and we can begin adding code specific to that library.

Figure 5 : A pod installed successfully using CocoaPods.

Figure 5 : A pod installed successfully using CocoaPods.

3. FontasticIcons

FontasticIcons is simply an Objective-C wrapper for iconic fonts. Those of you that work with CSS have probably been using iconic fonts for some time and there is plenty of reasons to do so. Some of those reasons include:

  • You can easily change the size, color, shape, opacity and more;
  • Since you are working with vector graphics, every icon looks great at any size and looks great on high resolution displays like Apple’s Retina screens;
  • Iconic Fonts do not require any sort of JavaScript to be displayed.

Since you already have CocoaPods installed, you can use FontasticIcons in your Xcode project by adding the following line in your Podfile as described earlier and then installing the Pod:

pod 'FontasticIcons'

Now if you open your xcodeproj file and navigate inside of Pods -> FontasticIcons -> Resources, you should pay special attention to the .string files. These files will let you know what icons are available as shown in Figure 6* below:

Figure 6 : Some of the default icons available after installation.

Figure 6 : Some of the default icons available after installation.

You can now reference them in code by adding code similar to the the following snippet that creates a button such as using the “camera” icon.

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.view addSubview:button];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
FIIcon *icon = [FIEntypoIcon cameraIcon];

FIIconLayer *layer = [FIIconLayer new];
layer.icon = icon;
layer.frame = button.bounds;
layer.iconColor = [UIColor blueColor];
[button.layer addSublayer:layer];

Looking at this code, we can see that we are creating a simple button and setting some simple properties on it. We then call set our icon with the cameraIcon on line 5. The only thing left to do is to add it as a layer and set the color.

Which will generate the following screen as shown in Figure 7.

Figure 7 : A sample iconic font in an iOS application.

Figure 7 : A sample iconic font in an iOS application.

If our customer decides they want it to be green instead of blue, then you would only have to change the following line instead of adding yet another image to the project:

layer.iconColor = [UIColor greenColor];

The new image is displayed in Figure 8.

Figure 8 : A sample iconic font in an iOS application.

Figure 8 : A sample iconic font in an iOS application.

The same could be said for the image dimensions. You may need 4 icons with different resolutions and you could do this just as easily by modifying the button.frame code.

Besides all of the icons already bundled, there is also a commercial-free library called Font Awesome that integrates nicely with FontasticIcons. As a matter of fact, some of the icons are already added to the default installation and can be found in the FontAwesomeRegular.strings file in the same Resources folder that we looked at earlier. However, you probably want to update it as the latest version includes 439 icons!

4. Prepo

Prepo takes the hassle out of preparing app icons and artwork with its simple user interface and drag and drop file support. You simply add in your icon artwork at 1024×1024 and it generates icons for iOS 1-7, iPhone or iPad and even gives you the option to add a “Shine” look and feel to it. After you are ready, you simply click the “Export” button and you have images available to drop directly into XCode. I’ve shown an icon sample in Figure 9 below:

Figure 9 : Some of the default icons available after installation.

Figure 9 : Some of the default icons available after installation.

You may optionally click the “Copy Plist” button and generate the code needed for XCode if you are not using the asset catalog as shown below.

<key>CFBundleIconFiles</key>
<array>
    <string>Icon.png</string>
    <string>Icon@2x.png</string>
    <string>Icon-60.png</string>
    <string>Icon-60@2x.png</string>
    <string>Icon-72.png</string>
    <string>Icon-72@2x.png</string>
    <string>Icon-76.png</string>
    <string>Icon-76@2x.png</string>
    <string>Icon-Small-50.png</string>
    <string>Icon-Small-50@2x.png</string>
    <string>Icon-Spotlight-40.png</string>
    <string>Icon-Spotlight-40@2x.png</string>
    <string>Icon-Small.png</string>
    <string>Icon-Small@2x.png</string>
</array>

There is also a @2x artwork option that will automatically convert and rename @2x images to @1x. Also, a paid plan is available, but the functionality described in this article is completely free.

5. CocoaLumberjack

CocoaLumberJack is basically a logging framework and a replacment for NSLog. It does much more than just log to the console; you can log messages to a file, console, or even a database if you wish. A lot of iOS developers love the ability to remove the log statements out of the release build and archive log files to review later.

With CocoaPods installed, you can use CocoaLumberJack in your Xcode project by adding the following line in your Podfile as described earlier and then installing the Pod:

pod 'CocoaLumberjack'

Head over to your AppName-Prefix.pch file and add the following code:

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
      #import <UIKit/UIKit.h>
      #import <Foundation/Foundation.h>
     #import "DDLog.h"
#endif

#ifdef DEBUG
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#else
static const int ddLogLevel = LOG_LEVEL_ERROR;
#endif

This will ensure that the macros contained in DDLog.h are available throughout the project, as well as set the ddLogLevel required by the framework. If we are running in debug mode, then we will set our log level to verbose. If we are in release mode then it will be logged as an actual error.

Switch back to your AppDelegate and add the following header files.

#import "DDASLLogger.h"
#import "DDTTYLogger.h"
#import "DDFileLogger.h"

You will also need to add the following code to your application delegate’s application:didFinishLaunchingWithOptions: method.

// Override point for customization after application launch.
[DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
return YES;

Switch over to your ViewController and add the following code:

DDLogError(@"This is an error.");
DDLogWarn(@"This is a warning.");
DDLogInfo(@"This is a message.");
DDLogVerbose(@"This is a verbose message.");

If you run the app, then you will see the following in your console window:

2014-07-02 18:11:32:373 TDNiOSApp[16749:60b] This is an error.
2014-07-02 18:11:32:374 TDNiOSApp[16749:60b] This is a warning.
2014-07-02 18:11:32:374 TDNiOSApp[16749:60b] This is a message.
2014-07-02 18:11:32:374 TDNiOSApp[16749:60b] This is a verbose message.

If you switch the scheme by selecting Product -> Scheme -> Edit Scheme and select “Release” as shown in Figure 10 then you will only get the first error message.

Figure 10 : Switch from Debug to Release in the Build Configuration.

Figure 10 : Switch from Debug to Release in the Build Configuration.

Figure 10 : Switch from Debug to Release in the Build Configuration.

The real magic comes in the form of Log files. Add the following code to your application delegate’s application:didFinishLaunchingWithOptions: method.

DDFileLogger *fileLogger = [[DDFileLogger alloc] init];
[fileLogger setRollingFrequency:60 * 60 * 24];
[[fileLogger logFileManager] setMaximumNumberOfLogFiles:7];
[DDLog addLogger:fileLogger];

Now if you deployed this in your simulator, navigate to the following directory:

~/Library/Application Support/iPhone Simulator/#ios simulator version no#/Applications/#yourapplication uuid#/Library/Caches/Logs/company_identifier_appname.date.log

If you open the file with the default program, then you will see what is shown in Figure 11.

Figure 11 : The Log file generated with CocoaLumberJack.

Figure 11 : The Log file generated with CocoaLumberJack.

Wrap-Up

We’ve looked at a variety of tools that can enhance your productivity developing apps using XCode. We started at looking at a package manager called Alcatraz, which makes it very easy to find, install and keep packages updated. Then we looked at our first dependency manager called CocoaPods which has thousands of libraries readily available. Now that we have a great way for developers to find what they need, they can rely on the help of FontasticIcons to get a great icon free of charge and Presto to resize it appropriately for all devices. We wrapped up with CocoaLumberJack which is a super-charged logging framework on steroids! With these 5 tools and XCode, you have nothing stopping you from creating awesome apps. So what are you waiting for, go build something awesome!

Now that you have seen all these useful tools, also check out our control suite that enriches the iOS SDK at http://www.telerik.com/ios-ui.

Comments

  • I suggest this online platform (available at http://arrray.com) to build simple and fast backend for our iOS app 🙂
    You can use Arrray also to make a test API (especially when the real backend it’s not ready yet).

    Enjoy!

  • Gabe

    Thanks for this informative post! These tools helps you explore your creativity. Innovation is in what the app does and not how you make it. Having the right set of tools can take your development quality to the next level. More at https://intellipaat.com/ios-development-training/

  • Abhimanyu Aryan

    Amazing article thanks. Subscribed.