Archiving for Release

Now that your app is coded, tested, and configured to your liking, it’s time to ship. Again, you’ll need to be registered with Apple’s Developer Program before attempting to upload an app. You can find instructions for installing your code-signing certificate and provisioning profile in the iOS Team Administration guide at the following URL:

http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/DevPortalGuide/CreatingandDownloadingDevelopmentProvisioningProfiles/CreatingandDownloadingDevelopmentProvisioningProfiles.html

Once that’s done, we’re good to go.

Before we finish the remaining settings in RubyMotion, you should add your new app or update in iTunes Connect (http://itunesconnect.apple.com). iTunes Connect is Apple’s developer front end to the App Store; before uploading your files, you need to complete all of the required information. Apple has a very thorough guide on using iTunes Connect that you can consult if you run into issues (at the following URL).

http://developer.apple.com/library/ios/#documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/1_Introduction/Introduction.html

SDK Version and Deployment Target

In your Rakefile, you should set what iOS SDK version you’re building against and what iOS versions you’ll allow the app to run on. By default, RubyMotion will use the latest and greatest SDK version for everything, but sometimes you may want to make your app available to older devices.

You can set the app’s sdk_version property to the stringified iOS version, such as "5.0". This will be the SDK your app is compiled against; in other words, your app will fail to build if you use APIs from newer SDKs. Apple usually only takes apps built against the most two most recent versions, so building against something like iOS 4.3 isn’t recommended.

On the other hand, deployment_target sets the lowest supported iOS version that our app can run on. But wait, how do we let our app run on operating systems older than what we compile against? In those cases, you need to check for the availability of classes at runtime using respond_to? and const_get.

For example, if we wanted to use some features of iOS6 such as Facebook integration but gracefully fall back to Twitter on older devices, our Rakefile would look like this:

 Motion::Project::App.setup ​do​ |app|
 # ...
  app.sdk_version = ​"6.0"
  app.deployment_target = ​"5.0"
 end

Required Configuration

Before we build our app, there are some options that need to be set. They aren’t necessary while we debug our app, but they are required before submitting to the App Store.

Your app’s version is the string displayed on your app’s App Store page and when listing available updates. It must consist of numbers and decimals, and each successive update must contain a higher version number. For example, "1.1" and "1.2.3" are valid versions; "1.3a" and "cat" are not.

The identifier is also required. When you create your app in iTunes Connect, you are required to create an App ID. These are created in the iOS Provisioning Portal and follow a reverse domain name format like "com.mycompany.myappname". RubyMotion provides a temporary default during development, but Apple will require a permanent unique ID when you submit your app.

Lastly, you need to set the provisioning profile used for releasing your app. provisioning_profile should be the complete path to the distribution profile you created in the iOS Provisioning Portal (if you haven’t, now is the time). The default location to install these is ~/Library/MobileDevice/Provisioning Profiles, but it’s fine if they’re placed anywhere. When testing on the simulator, RubyMotion uses the first development certificate it finds in that default location; however, building an app for the App Store requires you to use a specific distribution profile.

A robust App Store--ready Rakefile should look something like this:

 Motion::Project::App.setup ​do​ |app|
 # ...
  app.sdk_version = ​"6.0"
  app.deployment_target = ​"5.1"
  app.version = ​"1.0"
  app.identifier = ​"com.myappcompany.myawesomeapp"
  app.provisiong_profile = ​"/Users/me/profiles/1234.mobileprovision"
 end

Development vs. Release

Most software projects, including RubyMotion, have at least two build configurations: development and release. Development builds can include all kinds of debugging statements or even features that we don’t want to ship in the final product, while release builds should be safely isolated from any harmful or verbose code.

By default, running rake simulator or device will build the app in development mode; archiving the app for the App Store will build it in release mode. If you want to change your app build settings on a per-mode basis, you can use the development and release methods like so:

 Motion::Project::App.setup ​do​ |app|
 # ...
  app.development ​do
 # code runs in dev mode
  app.version = ​"1.0.1"
  app.identifier = ​"com.myappcompany.myawesomeapp.dev"
 end
  app.release ​do
 # code runs in release mode
  app.version = ​"1.0"
 end
 end

For a complete list of available options and more information, check out the RubyMotion project management documentation (http://www.rubymotion.com/developer-center/guides/project-management/).

Once everything is in place, the magic command is rake archive:distribution. This will build your app and place the final product in ./build/iPhoneOS-SDK_VERSION-Release/APP_NAMEipa. This archive contains your application binary and resources and is signed using the distribution certificate you created when signing up for a developer account.

Now that we have our finished ipa, we can use the Application Loader, which ships with Xcode to upload our app.

images/uploading/app_loader.png

Before you upload the archive, you’ll need to have your app data added on iTunes Connect. Once the status of your app on iTunes Connect is “Waiting for Upload,” follow the instructions given in Application Loader to complete the process. After that, all you have to do is wait for Apple to approve your app!

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

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