Turbocharge Your iOS Development: Cocoapods, fastlane, and Xcode Tutorial
Today I’m here to talk to you about making your iOS development better, faster, and more effective than ever before. I will be going over a few external tools that are widely used by iOS developers around the world and I will provide a few helpful built-in features of Xcode.
Utilizing these tools has saved me not just minutes and hours from my development time, but days and weeks.
Cocoapods is a dependency manager for iOS. That’s a fancy way of saying “It’s a tool that makes it easy to include other people’s code/frameworks into your own project.”
Cocoapods has become one of the most popular tools in the iOS developer world and should be at the top of your list of tools to integrate into your workflow.
How does it work?
After installing Cocoapods, your project will contain a simple text file called a Podfile. This file includes references to frameworks from other developers.
Using the command-line tool, Cocoapods will automatically download all of the required files, integrate them inside your project, and even add the required frameworks.
It’s a simple way to keep track of all the third-party frameworks you have in your project, which makes it very easy to update and manage them.
To learn more about how to install Cocoapods, be sure to check out our other tutorial, Adopting Cocoapods in your iOS app.
Fastlane is an incredibly powerful command-line tool that makes building and submitting your apps to the App Store fast and efficient.
If you’re an iOS developer with apps in the App Store, you know the routine. Build your app, check it for errors, attempt to submit to the App Store, get rejected and be presented with an obscure error message. Perhaps a provisioning issue exists, a
missing.plist value or something more sinister.
Fastlane aims to cut down the time needed to submit builds by making sure that all of the tedious tasks are done for you. That means you can issue a single command and let fastlane do all of the hard work.
Exploring fastlane’s tools
After installing fastlane, you must include a simple text-based file called a Fastfile inside your project. If you’re already familiar with Cocoapods, it’s essentially the same thing — a file that tells the tool exactly what it should do.
Fastlane comes with a number of different tools to help you submit your applications to Apple. Today, I will focus on three of them.
This tool automates the tedious task of taking screenshots. In the past, developers would have to manually run their app on each device size, take screenshots, and gather them together for submission. If your iOS app has more than one language, you would need to repeat the process multiple times for each language. Snapshot takes localized screenshots on every device size each time you submit your app to the App Store. What used to take a developer days to accomplish, now takes a single command and a few minutes.
It’s no secret that iTunes Connect is kind of horrible. It looks decent enough, but below the surface lies a tool that can cause frustration for even the most seasoned developers. Sure, it’s gotten better over the years, but the one thing that has been a continually terrible process is adding screenshots.
You’ll be happy to know that fastlane can not only take your screenshots, but also deliver them to iTunes Connect.
Sigh is a fastlane tool that takes care of the provisioning details for your application. Provisioning is a common source of frustration in iOS development. Sigh simplifies the application process by downloading, renewing, repairing and creating provisioning profiles automatically.
When fastlane was first released, it didn’t “click” with me just how important of a tool it was. After a bit of time, I revisited it and dedicated a few hours of time into learning exactly how it worked. I was shocked and amazed at how helpful of a tool it was. Needless to say, it quickly became one of my favorite tools and earned its coveted spot in my developer tools library.
Xcode’s built-in features
Xcode has a ton of cool and helpful features that developers may not know about due to the massive scope of the application. Developers often times only use the tools they have been taught and ignore the rest until someone tells them otherwise or until they unintentionally stumble across them themselves.
While it’s understandable, exploring Xcode and all of its features is crucial because it will make you a better and a more efficient developer.
Exploring Xcode tools
Don’t laugh, but I did iOS development for years without using the simple multi-tab feature of Xcode. It’s become an essential feature in my day-to-day work. It makes me shake my head and mumble a few choice words every time I think about how long it took me to find this feature.
The tabs feature in Xcode is especially powerful because it allows you to customize the contents of the tab. One tab could have a single editor pane with the debugging area showing output, and another with multiple editor panes.
Tip: Double-click a tab to rename it. This creates an interface template which can be used in Xcode’s Behaviors feature (see below).
Behaviors is a feature of Xcode that allows you to specify how you want it to act when a certain event happens. You can have Xcode play a specific sound when running your app or even customize the user interface of Xcode after an event.
You can use Behaviors to open that specific tab when an Xcode event occurs such as building your app.
Many people are familiar with the built-in snippet manager in Xcode. Fewer people know that you can also add your own snippets to the library.
Strangely enough, Xcode doesn’t announce the fact that it’s possible to have user-defined snippets. There is no “+” button on the interface nor an indication in the application menu. To add your own snippet, make sure the snippet manager is open, then simply highlight your selected code and drag and drop them into the snippet manager area. You’ll get a popup box to confirm your new addition and, just like magic, it’ll be saved.
If you want some more tips on how to use Xcode for different functions, check out tutorials such as Create a Facebook Share Button and Twitter Tweet Button for Your iOS Swift App or ask some Codementors for guidance!
That’s it for today! I hope you’ve enjoyed learning about a few tools and features that can help turbocharge your iOS development. Adopting these in my own projects have helped me become a more well-rounded developer while saving me lots of time in the process.
Ryan Hartman is a senior iOS developer with over 7 years of experience creating awesome apps for iOS and Mac. Located in beautiful Berlin, Germany, he is passionate about helping others learn about programming, UI/UX design, and other technical topics.