Book Image

RubyMotion iOS Development Essentials

Book Image

RubyMotion iOS Development Essentials

Overview of this book

RubyMotion is a revolutionary toolchain for iOS app development. With RubyMotion, you can quickly develop and test native iOS apps for the iPhone and iPad, combining the expressiveness and simplicity of Ruby with the power of the iOS SDK. "RubyMotion iOS Development Essentials" is a hands-on guide for developing iOS apps using RubyMotion. With RubyMotion, you can eliminate the complexity and confusion associated with the development of iOS applications using Objective-C. We'll begin from scratch. Starting by installing RubyMotion, we'll build ourselves up to developing an app that uses the various device capabilities iOS has to offer. What's more, we'll even learn how to launch your app on the App Store! We'll also learn to use iOS SDK classes to create application views. Discover how to use the camera, geolocation, gestures, and other device capabilities to create engaging, interactive apps. We'll develop stunning user interfaces faster with the XCode interface builder and make web apps by using WebView. We'll then augment applications with RubyMotion gems, doing more by writing less code and learn how to write test cases for RubyMotion projects. Finally, we'll understand the app submission process to push your app to Apple's App Store With "RubyMotion iOS Development Essentials", we will learn how to create iOS apps with ease. At the end of each chapter we will have a tangible and running app, which utilizes the concepts we have learnt in that chapter.
Table of Contents (19 chapters)
RubyMotion iOS Development Essentials
Credits
About the Authors
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

With the arrival of the iOS family of devices, the direction of software development has radically changed. Today people are spending considerable amounts of time on smart devices instead of PCs, which is generating an unprecedented amount of revenue that no industry has ever seen. Despite this, it still fits in your pocket.

So far the application development scene for the iOS ecosystem has been dominated by Objective-C. However, with the introduction of the revolutionary RubyMotion tool chain, Ruby developers are no longer outcasts for creating pure native iOS applications. They can make use of every bit of the all-powerful iOS SDK; and the best part is this can be done without using Xcode.

Both Ruby and RubyMotion are the brainchild of folks who wanted to simplify things in a complex world. Yukihiro Matsumoto (also known as Matz) is credited for creating the Ruby programming language, which is often regarded as a developer's best friend. And Laurent Sansonetti is credited for creating the ground-breaking tool chain, RubyMotion.

RubyMotion iOS Development Essentials will appeal to a developer's mind, especially to the technocrats looking for a reliable tool chain for iOS development. This book] is a step-by-step guide to build an iOS application from scratch to deployment.

What this book covers

Chapter 1, Getting Ready for RubyMotion, gets you acquainted with RubyMotion. Here, we will start with an introduction to RubyMotion, followed by detailed installation steps.

Chapter 2, Instant Gratification – Your First Application, explains how to create a simple Hello World application and also the structure of RubyMotion applications in general.

Chapter 3, Evolution – From Objective-C to RubyMotion, helps you understand the journey from Objective-C to RubyMotion. This chapter is also a quick guide to understanding the RubyMotion syntax corresponding to its Objective-C syntax.

Chapter 4, Mastering MVC Paradigm, focuses on writing better code with the Model-View-Controller architecture. We will also learn about connecting the application to an external API.

Chapter 5, User Interface – Cosmetics for Your App, describes how the user interface is a key part of an iOS application. Also, this chapter explains how we can use the various user interface elements.

Chapter 6, Device Capability – Power Unleashed, teaches you how to use various device capabilities, such as Camera, Location Manager, Gestures, Core Data, and Address Book. We will create sample applications for each one of them to understand them better.

Chapter 7, Interface Builder and WebView – More Goodies!, explains how to use the interface builder and UIWebView with RubyMotion applications.

Chapter 8, Testing – Let's Fail Gracefully, discusses Unit Testing and Functional Testing in a RubyMotion application by following the philosophy of Test-driven Development.

Chapter 9, Creating a Game Application, helps you create a popular arcade game, Whack-a-Mole, using Cocoa2D and RubyMotion. This is one of the most exciting and unique features of working with RubyMotion where it's possible to create graphical gaming applications.

Chapter 10, Getting Ready for the App Store, explains the process of submitting a RubyMotion application to the Apple App Store.

Chapter 11, Extending RubyMotion, describes how to augment our RubyMotion applications by making use of the already available open source gems, such as TeaCup, BubbleWrap, and Address Book.

What you need for this book

To program with RubyMotion, firstly you require a Macintosh computer. Since RubyMotion is proprietary software, you are required to buy its license from http://sites.fastspring.com/hipbyte/product/rubymotion.

Who this book is for

This book is for developers who are well versed with the Ruby programming language, and are interested in developing native iOS applications. We do not expect you to have any prior knowledge of RubyMotion. With RubyMotion iOS development essentials, we will discover features of this amazing tool chain from beginner to pro level.

Prior knowledge of Objective-C and the iOS SDK can come in handy at times, but no worries, we have covered every little detail to make you a maven by the end of this book.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Create a contact_us_controller.rb file inside the app folder."

A block of code is set as follows:

    @submit_button.addTarget(self,
            action:''send_message'', forControlEvents:UIControlEventTouchUpInside)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

def setupNavigationBar
  back= UIBarButtonItem.alloc.initWithTitle(''Back'', style:UIBarButtonItemStylePlain,target:nil ,action:nil)
  self.navigationItem.backBarButtonItem = back;
  contact_us_button = UIBarButtonItem.alloc.initWithTitle(""Contact Us"", style:UIBarButtonItemStylePlain ,target:self, action:""contact_us"")
  self.navigationItem.rightBarButtonItem = contact_us_button
end
def contact_us
  contact_us_controller = ContactUsController.alloc.initWithNibName(""ViewController"", bundle:nil)
  presentModalViewController(contact_us_controller, animated:true)
end

Any command-line input or output is written as follows:

$rake

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: "Open Xcode and click on Create a new Xcode Project."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.