objective c

3 results

Mobilize Your MongoDB Part IV: Using the Beershift Source Code

During Part 3 of the developing iPhone and Android apps in the cloud series, we went over signing up for a brewerydb.com account as well as downloading and deploying the BeerShift backend source code on OpenShift. In this blog post, we will discuss the mobile application code and get it working inside of Titanium Studio. If you haven’t already installed and configured XCode, Titanium Studio, and the Android SDK, please follow the steps outlined in Part 2 of this series. Step 1: Clone the BeerShift project In order to start working with the mobile application for BeerShift, we need a local copy of the open sourced code that is available on github. If you are not familiar with git, we are going to clone the BeerShift repository. This will copy the BeerShift source to our local machine as well as setup a local source code revision control repository that is private. This will enable us to make changes to the source code and commit them to our local private repository. Any change that you commit to BeerShift on your local machine will remain private. If you add some fancy new features, or fix some bugs, you will need to issue a pull request on github in order for the public repository to be updated with your changes. In order to clone the BeerShift source code, open up a terminal window and create a directory for your project. $ mkdir ~/code $ cd ~/code Now that we have a location for our source code, lets clone the BeerShift repository. $ git clone https://github.com/BeerShift/BeerShift.git This will create a directory named BeerShift underneath the code directory. To verify that you have the proper source code, lets view some of the commit log. $ cd BeerShift $ git log At this point, you should see the last several contributions to the project. Step 2: Import the project into Titanium Studio Start Titanium Studio and select 'Import Project' on the left hand side of the screen. Select 'Existing Titanium Project' and click 'Next'. Select the location of your source from Step 1, and click on the 'Finish' button. Step 3: Set your deployment targets Now that we have the source code imported into Titanium Studio, we need to set the deployment targets for our application. Double click on the tiapp.xml file that is located under your project directory. If you are on the Mac operating system, and followed all of the steps in Part 2 of this blog series to install XCode and the Android SDK, select iPhone and Android. In you are on Windows or Linux, you will not be able to target iOS devices. Step 4: Understand the directory structure In your 'App Explorer' pane, you should see two top-level directories. The i18n directory is where you can place all of your localization files for your application. Localization in Titanium Studio is pretty straightforward and I will detail how to add the users default locale to your application. Under the i18n directory, you should create a subdirectory for each language / locale that you plan to support (based on the ISO 639-1 standard). For instance, to support both English and German, create two directories: en and de In each locale specific subdirectory, you will need a strings.xml file that is an xml based key->value pair. For example: <?xml version="1.0" encoding="UTF-8"?> <resources> <string name="lblBeerName">Beer Name: </string> <string name="tfBeerName">What am I drinking?</string> <string name="tabDrink">Drink</string> <string name="winDrank">Drank</string> <string name="winFirehose">Keg Stand</string> <string name="tabDrank">Drank</string> <string name="winSettings">Settings</string> <string name="tabFireHouse">Keg Stand</string> <string name="tabSettings">Settings</string> <string name="winDrink">BeerShift</string> <string name="winBeerDetails">Beer Details</string> <string name="lblDrinkTheBeer">Drink It!</string> <string name="lblLoading">Loading......</string> <string name="titleLabelText"> drank </string> <string name="lblApi">URL: </string> <string name="lblApiHintText">Service URL</string> <string name="lblUsername">Username: </string> <string name="tfUsernameHintText">BeerShift Username</string> <string name="lblPassword">Password: </string> <string name="tfPasswordHintText">password</string> <string name="lblAuthenticating">Authenticating</string> <string name="alrtDialogTitle">Bad Password</string> <string name="alrtDialogMsg">Password is not correct for this user</string> <string name="createUserTitle">That user doesn't exist. Would you like to create it?</string> <string name="labelYes">Yes</string> <string name="labelNo">No</string> </resources> These resource files are processed and included in your project at build time. Step 5: Getting started with the source code Expand the 'Resources' directory and double click the app.js file. The app.js file acts like a bootstrap for your application. This is the first file that gets loaded and is where you define and create your layout and application. Instead of walking through the source code in this blog post, check out the video where I walk through the code and explain what is happening. Step 6: Test your application in the simulator Now that we have and understand the source code, lets see it running inside of the iPhone or Android emulator. In order to run the application, select 'Run' and then select 'Run' again. This will open a dialog that will allow you to select which run configuration to use. Once you select your device, Titanium Studio will build your application code and launch the emulator. At this point, you can play around with the application and even set breakpoints and debug inside of the emulator. Step 7: What’s next? You should have the application up and running and hopefully pointed to your own backend hosted on OpenShift. The next step is to add a cool feature or fix a bug that is present in the source code. Once you have modified the code, submit a pull request on github and I will work to get it accepted into the master source code branch. If you haven’t already signed up for OpenShift, take a moment to do that now. Use the promo code ‘BeerShift’ to claim your 3 free applications running on the Red Hat Cloud. Want to see me give a presentation on mobile development? I will be at the following upcoming events: OSCON 2012 - July 17-20 Phoenix PHP Users Group - July 24th Fredricksburg (DC) Linux User Group - July 28 WIP Hackathon, Detroit - July 30-31 MongoDB Toronto - August 2 FOSCON - August 11 MongoDB Charlotte - August 15 NOSQL Now - August 21-23 Want me to come and speak at your users group or conference? Send an email to openshift@redhat.com and we can co-ordinate scheduled. Tagged with: Titanium, objective c, SDK, git, openshift, iphone, android, iphone development, beer, MongoDB, Mongo, NoSQL, Polyglot persistence, 10gen

July 12, 2012

Mobilize Your MongoDB: Building MongoDB Mobile Apps with OpenShift PaaS Part II

Summary: This is the second part of a blog series that details how to develop a mobile application that is backed by MongoDB and a PaaS. MongoDB makes a great companion to this mobile application given its ability to shard and the nature of being able to store JSON documents with little data manipulation required. In this blog post, part two of the series, we will go over the required components and software in order to develop cross platform mobile applications for the iPhone and Android operating systems. We will also install and configure the backend systems, including mongodb , which makes a perfect data store for the BeerShift mobile application. We will be using the following applications and software stack components: Titanium Studio by Appcelerator Titanium Studio is an all-inclusive powerful Eclipse-based IDE that simplifies the mobile development process. Use Titanium Studio to rapidly build, test, package and publish mobile, desktop and web applications. Take advantage of new functionality like advanced code assisting, ACS integration, module management, Git integration, an enhanced publishing workflow and a full-featured editor. Manage Titanium projects, test your mobile apps in the simulator or on device, automate app packaging deploy to a public or private App Store and much more. * Xcode by Apple Even though we will be using Titanium Studio for our development, we will still need to have Xcode installed and configured so that we have access to several important tools. Not only will we be using the simulator to test out our iPhone application, we will also need the Xcode IDE in order to bundle and submit our application to the Apple App Store. Android SDK Since we are targeting both iOS and Android based devices, we will also need to install and configure the Android SDK for emulating the Android hardware for testing. OpenShift Client Tools OpenShift is Red Hat’s free, auto-scaling Platform as a Service (PaaS) for applications. As an application platform in the cloud, OpenShift manages the stack so you can focus on your code. We will be using this for our backend services and our cloud hosted MongoDB . While not required for this blog post series, I would suggest that a user also install a quality image editing application for sizing of icons and splash screens for your application. I prefer to use an open source software application called Gimp that will provide the user with most of the image editing capabilities they need. Step 1: Installing Xcode Note: If you are planning on targeting iOS platforms, you will typically need an iOS developer account . This will allow you to publish your application to the Apple App Store and receive product updates and announcements about new iOS platforms. This program typically costs 99.00USD per year. There are generally two ways to install Xcode on Mac OS. You can either install via the app store or you can download it directly from the Apple Developer Center. During this blog post, I will assume that you have access to the Apple App Store and will be detailing that route in order to install the IDE. Once you start the App Store application, search for Xcode and you should be directed to the following page: Once on this page, click the free button under the short description in order to install the IDE on your local operating system. Once the installation starts, be patient! Xcode is 1.5 gigs and can take up to a significant amount of time to install even on the fastest of connections. To check the status of the installation, you can go back to the App Store application and click on the Purchases tab at the top of the screen. This will display your current download position and how much time is remaining. Step 2: Installing OpenShift Client Tools Note: If you would rather watch a screencast of this step, check out this video where I demo how to install the client tools on OSX. The OpenShift client tools are written in a very popular programming language called Ruby . With OSX 10.6 and later, ruby is installed by default so installing the client tools is a snap. Simply issue the following command on your terminal application: $ sudo gem install rhc If you don't already have an OpenShift account, head on over to http://openshift.redhat.com and signup. It is completely free and Red Hat gives every user three free applications running in the cloud. At the time of this writing, the combined resources allocated for each user is 1.5gb of memory and 3gb of disk space. Now that we have the client tools installed, we also need to install the GIT source code repository tools. In order to do this, download the package from the GIT website by clicking on the Download for Mac button on the right hand side of the screen. Once the download of is .dmg file is complete, mount the image by clicking on it and open up Finder. Once Finder is open, click on the .pkg file to install GIT to your local system. Follow the installation instructions and close the dialog box once the installation has finished. Open up a new terminal window to ensure that your environment variables, including your path, have been updated to reflect the new git installation. At this point, we can create the backend server for our BeerShift application including the mongo database. For this blog post, we will be using a PHP backend but I have also written a backend for Ruby, Python and Java. $ rhc app create -a beershift -t php-5.3 The above command will provision some space for us on the Red Hat Cloud. It will also create a templated website for us to verify that the application creation was successful. Once the command has finished, verify that the application and server space was created by pointing your browser to the URL provided by the RHC tools. Now that we have an application created, lets create a mongodb data store to house our application data. This can be done by performing the following command. $ rhc-ctl-app -a beershift -e add-mongodb-2.0 This will return the database hostname, port, root user and root password for you to access the database. Don't worry, we will go into more detail on how all of this works with the blog post that covers the backend system for this application. Step 3: Install the Android SDK Appcelerator provides excellent instructions on how to install and configure the Android SDK for use with Titanium Studio. Instead of re-inventing the wheel, I suggest that you follow the instructions already provided for this step. Step 4: Install Titanium Studio In order to install and use Titanium Studio, you will need to register for a developer account with Appcelerator. Head on over and click the Download Titanium button on the right hand side of the screen. This will redirect you to a sign up screen. Fill in the required details and submit the form and check your inbox for a validation email. Once you have validated your email, you will be redirected back to the Appcelerator site where you can download Titanium Studio. Once the .dmg file has downloaded, mount the image and follow the instruction to drag Titanium Studio to your Applications folder. Note: When you start the application for the first time, you may be prompted to install a Java runtime. If so, following the instructions that are presented and OSX will automatically find and install the Java runtime for you. Once Titanium Studio starts, you will be prompted for a location to store your workspace. The workspace is a location on your local machine where all of your source files and project settings will be stored. After you select your workspace location, you will be asked for your username and password. This is the username and password that you used to signup for an Appcelerator account. Once you are logged in, that IDE may perform an update to ensure that you are running the latest available code. Now that you have the IDE setup and your SDKs setup, get familiar with the IDE and play around with a few of the sample projects. In the next blog post we will begin development of the backend application and create our REST API that handle communication between the mobile application and the cloud hosted server. * http://www.appcelerator.com/platform/titanium-studio Tagged with: openshift, sdk, iphone, iphone development, objective c, red hat, open source, MongoDB, Mongo, NoSQL, Polyglot persistence, 10gen

May 31, 2012

Mobilize Your MongoDB: Building MongoDB Mobile Apps with OpenShift PaaS

This is the first in a 4-part series by Grant Shipley, Cloud Evangelist for Red Hat’s OpenShift Platform-as-a-service. Grant’s series will cover the development of “Beershift”, a mobile app for iPhone and Android built using Titanium, OpenShift and MongoDB. MongoDB makes a great companion to this mobile application given its ability to shard store JSON documents with little data manipulation required. In this blog post, we will go over the background of the application and discuss the features we plan to build. Background: I started developing iOS based applications shortly after the arrival of the iPhone on the market. Having been a Java and PHP developer for my entire career, switching to objective-c was a tough challenge for me. I had to remember basic programming methodologies and patterns that I haven't used since college. It took me nearly two months of work at the cadence of 30-40 hours per week to build my first iOS application. To my delight, after releasing the application, the market for the application was larger that I had anticipated. Users were writing great reviews and requesting more features. Shortly after releasing my first iOS based application, Google decided to enter the smartphone market with their android based sdk and devices. This should have been great news for most software developers but for me, a part time mobile developer, it wasn't. I now had users requesting my application for android devices as well as for the new iPad and other tablets that were hitting the market. I didn't have the free time to port my application to the android sdk as it would have required another two months of software development as well as maintaining two separate code streams for patches and updates. About 8 months ago, I heard about a company called Appcelerator and their Titanium SDK . This SDK would allow me to code using javascript but target native UI controls for an array of devices. This sounded like heaven as most of the applications that I write are productivity or novelty based applications that don't rely heavily on 3D graphics. I set out to learn the titanium SDK and was able to develop the BeerShift sample application over a period of two days. About BeerShift: At OpenShift , we enjoy local craft beers and the social aspects of having a pint while discussing the latest trends in software development and deployment. One night, over a pint, we thought it would be cool if we could quickly read a description of the beer and brewery before ordering. We kept discussing the app and of course feature creep started setting in. By the end of the night, we decided to develop a mobile-based application that would allow a user to search for beers, and then log when and where they drank it. Because the team was split between using iOS and Android based phones, we needed it to work on both devices and sync the information via a backend service. Of course, all of this had to be available via the web as well. This was a great opportunity for me to learn Titanium so I set out to develop the application. The biggest unknown was where to get a freely available database of beers that I could search. I researched this question and did some google searching but didn't really come up with any providers that met my needs. Luckily, while speaking at a PHP Users Group in Raleigh, NC, I met a couple of guys who owned a startup called brewerydb.com . With their growing repository of beers and breweries, it had all of the information that I needed in order to develop the sample app. I invited them out for a pint after the user group and we discussed the details. A few days later I had an API key and was ready to get my Titanium Javascript on. Want a quick preview of what we will be building? Check out the video showing the application. BeerShift has a tabbed based UI that consists for 4 main screens. Drink, Drank, Kegstand, and Settings. The settings tab presents the user with username and password input fields. If the username does not exist in the MongoDB database, the user will be prompted if they want to create a new user. The drink tab is the heart of the application. This tab allows the uses to enter in a beer name and will return a result of all beers and breweries that match the search string. The results are retrieved via a REST API call to the openshift server and presented to the user in a table view. The user can select a a beer from the list and then select to ...Drink It“. Once the user has decided to log drinking a beer, the drinking event will be recorded on both the drank tab and the keg stand tab. The keg stand tab will allow the user of the application to view the 50 most recent beers drank by any user of the application. In the next blog post of this series, I will detail the installation of applications and tools needed to begin with development of the BeerShift application. Source Code: All of the source code for this application, including the backend REST API and MongoDBa> integration, is available on github.com/gshipley Tagged with: red hat, open shift, openshift, mobile, apps, application, titanium, sdk, java, objective c, open source, breweries, beer, brewerydb, MongoDB, Mongo, NoSQL, Polyglot persistence, 10gen

May 15, 2012