Setting up the RubyMotion project

Next, let's set up our RubyMotion project; it will include the information we have collected previously.

Entitlements

Entitlements are used during the code-signing part of the build process. Many applications require access to device features; Apple requires you to specify the entitlements if you want to access a specific device feature. This can be added in the Rakefile. The entitlement method in the Rakefile lets you specify the appropriate keys and values in the following way:

Motion::Project::App.setup do |app|
  # ...
  app.entitlements['keychain-access-groups'] = [
    app.seed_id + '.' + app.identifier
  ]
end

In this example, if your application requires access to a keychain to store user credentials, you must send a request for keychain-access-groups by passing the application provisioning identifier and application identifier along with seed_id and the app identifier.

Info.plist settings

To provide the best experience to the users, iOS expects the presence of meta information in each application. This information is then used in various ways. Some of it is displayed to users and some may be used internally by the system to identify the application. These configuration settings are defined in Info.plist, which resides in the application's bundle.

In a RubyMotion project, the Info.plist file is defined in the Rakefile in a hash-like structure where you have a key-value pair. For example, we define CFBundleURLTypes in the following example:

Motion::Project::App.setup do |app|
  # ...
  app.info_plist['CFBundleURLTypes'] = [
    { 'CFBundleURLName' => 'com.packtpub.restroapp'}
    
  ]
end

The Rakefile does not cover all the possible settings, but it reveals the internal Info.plist data structure that one can modify, if at all needed. For more information and to check a list of other Info.plist properties, you can visit the Apple developer reference at http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html.

Building icons

Now that our machine is set up for the App Store, let's set up our RubyMotion project too. The first thing to do here is to set build icons. Since iOS devices, such as the iPhone, iPad, iPad mini, and retina displays come in a variety of screen sizes and display resolutions, Apple provides specific guidelines for creating icons to cater to each of them.

For our application icons, simply add these icons in the resources folder. They can have any random name, but it is a good idea to name them descriptively according to what they represent, such as icon_name-114 or icon-1024. Here, 114 and 1024 represent the size 114 x 114 for a standard app icon and 1024 x 1024 for an App Store icon, respectively.

Next, add the icon attribute in your Rakefile in the following way:

Motion::Project::App.setup do |app|
  # Use `rake config' to see complete project settings.
  app.name = 'Restaurant Application'
  app.icons  =  ['icon-114.png']
end

By default, these icons have a glossy effect on the upper half of the image, which is the traditional iPhone style. But you can change this by adding the following lines in your Rakefile:

Motion::Project::App.setup do |app|
  # Use `rake config' to see complete project settings.
  app.name = 'Restaurant Application'
  app.icons  =  ['icon-114.png']
  app.prerendered_icon = true
end

That's it. Our RubyMotion application is now ready with icons. Some tips for designing great icons are as follows:

  • For best results, enlist the help of a professional graphic designer
  • Use universal imagery that people will easily recognize
  • Embrace simplicity
  • The richer the icons are in texture, the better they are to look at
  • Make the icons more detailed and more realistic
  • Add detail and depth

As icons provide the first impression of your application, you must work extensively to ensure they look good. You can find more information related to icons and designs on the Apple developer reference at http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html.

Besides icons, we can have other resources, such as images and sound files. These can be included in the resources folder, and instances of these can be used throughout our application. For example, we can create the instance of the hello.png image with UIImage.imageNamed("hello").

Configuring your application

Before we create the package that will be uploaded to the App Store review, we need to add some configuration settings so that Apple can recognize that the application is from a registered source. Here we will use the information from our provisioning profile, plus some general information related to our application.

All these settings, once again, go into our Rakefile. Some of the required settings that need to be fed are our iOS SDK version that we are using and our application version, such as 1.0, 1.3, and 2.0, which is always incremented for future releases. The deployment target is a minimal iOS version on which we want to run our application or anything that will work fine with our application. We also need to specify our identifier and provisioning profile details. This will be clear with the following example:

Motion::Project::App.setup do |app|
app.sdk_version = "6.0"
app.deployment_target = "5.0"
app.version = "1.0"
app.identifier = "com.packtpub.restroapp"
app.provisiong_profile = "/Users/your_name/Provisioning_Profiles/random_sequence.mobileprovision"
end

Note

The provisioning profile details are different for development and distribution. Distribution profile details are used only when we want to submit or test apps on many devices.

Installing on a device

It's a good idea to test your application before you submit it to the App Store. Now that all our settings are in place, we just need to run the rake device command from the console. Before doing so, make sure your registered device in the provisioning portal is connected via USB to your Mac machine. The process may fail for any of the following reasons:

  • The registered device is not connected to your machine via a USB
  • An incorrect identifier or provisioning profile's details have been added
  • The project uses an incorrect iOS version that is running on the device

iTunes Connect

Now we are done; but just before we create our application bundle and upload it, we need to set up our application on a separate portal (https://itunesconnect.apple.com). iTunes Connect has many options related to your application, such as Sales and Trends, Catalog Reports, Developer Forums, Payments, Manage Your Application, Manage Users, and many more. But, for now, we are just interested in the Manage Your Application option:

iTunes Connect

Once you have chosen Manage Your Applications, click on the button to add a new application to your catalog. This will show you the following form:

iTunes Connect

Enter your application's name in the App Name textbox. The SKU number is a desired, unique alphanumeric sequence that you have to enter. Select a Bundle ID option from the drop-down menu; since your iTunes Connect profile is coupled with your provisioning portal, you will get the right options in the dropdown automatically.

Once submitted, you will get the option of when to release the application, choosing the price tier (free or paid), and choosing which App Store will sell the application based on various countries. Following this window, another form will appear where you will have to fill in the description of your application, upload snapshots of various devices, add icons for the App Store, and fill in other logistic details, such as who to contact for support in case there are some issues related to the application.

Now that our application has been set up on iTunes Connect, we will next learn how to push our app for the App Store review.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.165.171