Showing posts with label rhomobile. Show all posts
Showing posts with label rhomobile. Show all posts

Thursday, November 24, 2011

Rhodes Iphone Build using Xcode


In this post we will create Rhodes build from Xcode. Though we can do this by rake run:iphone for development and rake run:iphone:production for Production but for better understanding and advance configuration we can do the same with Xcode. 

To start quickly,  these are the prerequisite:
  •        Valid Provision Profile should be installed.
  •        Valid Certification should be installed.

For getting these Certification login to Apple Development Center and navigate to iOS Provisioning Portal.

Now to get started follow these steps:
  •    Go to your project folder from Terminal and type:          

             $rake switch_app

The switch_app command changes the rhobuild.yml in the Rhodes source code folder to point to your application, as in the following example for a Rhodes application named Store in the user’s home folder:

env:   
    app: /Users/Name_Of_User/Application_name
  
  • Now run the following command to tell Rhodes to set up the Xcode environment for your Rhodes application:

          $ rake build:iphone:setup_xcode_project

  •    Open rrhorunner.xcodeproj project. This will open your application in Xcode. You can find this project in Gems folder of ruby -> Rhodes-> Platform-> iphone. After opening the project we can see rhorunner project is open in Xcode.


  • To run the application select rhorunner project and then select where you want to run the application. If you have connect iOS device it will appear on list for example in given image I have connected my iphone "Abhishek Nalwaya's iPhone"





If we select "Abhishek Nalwaya's iPhone" and click on Run then it will automatically create the build and install the application on the device. To run in the simulator you can select from the list. 

Debugging Notes: 
  • Make sure you have register the device to appstore for testing.
  • Make sure you have selected correct Code Signing 


  • If you want to restore the XCode use following command:

              $rake build:iphone:restore_xcode_project


If you face any issue feel free to comment on this post.


Sunday, March 27, 2011

Changing Rhosync URL dynamically

We may need that we want to change rhosync server URL dynamically. We can change using  Rho::RhoConfig API

SyncEngine.set_syncserver('http://newurl/application')


Calling the function above will do the following:

  • Update the in-memory syncserver for the SyncEngine 
  • Perform a logout to make sure the session for the old syncserver is removed
  • Write the new syncserver property to rhoconfig.txt

Wednesday, October 27, 2010

Create a Rhodes application which will sync data from rails application using Rhosync

In this blog we will create a Rhodes application which will synchronize your data from rails application through Rhosync.
We need to create 3 applications
  1. Rails Application: It will feed data in json or XML format.
  2. Rhodes Application: This code will be installed in mobiles.
  3. Rhosync Application: These will sync the data from rails App to Rhodes Application in your phone
Steps to create rails Application:
I will just create a rails application using scaffold:
  1. rails employee_details
  2. cd employee_details
  3. Ruby script/generate scaffold employee name:string phno:integer address:text
  4. Update your database.yml 
  5. Rake db:migrate
  6. Add these code in your employees controller (you can skip this step if you want to only show employee details and does not do crud operations.)
              protect_from_forgery :except => [:create, :update, :delete]
    
    7. Add this line under response in controller:
             
             format.json { render :json => @employee }

    8. Once it is done we will run it on port 3000:

              http://localhost:3000\employees.json

         we will get output in json format.


Steps to create Rhodes application:
  1. Rhogen app employee
  2. Cd employee
  3. Rhogen model employee name,phno,address
  4. Add link in index.erb to your index page
  5. Enable sync in model Employee  
                enable :sync


    6.   Edit rhoconfig.txt file and set
             syncserver = 'http://localhost:9292/application
    7.    rake run:bb


Steps to create Rhosync application:
  1. Rhosync app employee_server
  2. Rhosync source employee
  3. Then employee.erb incude json and rest client
          require 'json'
          require 'rest_client'

     4. Update the query method

  def query(params=nil)
    parsed=JSON.parse(RestClient.get("http://localhost:3000/employees.json").body)
    @result={}
    parsed.each { |item|@result[item["employee"]["id"].to_s]=item["employee"] } if parsed
    @result
  end

Now you can test this by login to your simulator.





Wednesday, August 18, 2010

Rhodes Installation

Installing Rhodes(Rhomobile)
These are the steps to install rhodes
Step 1 : Install Ruby: Better download window installer for Ruby 1.8.6 or 1.8.7. I am using ruby 1.8.7 and it work good for me. You can download it from http://www.ruby-lang.org/en/downloads/
Note : Don’t forget to add ruby to your path(It will ask you while installing ruby). You can test it from command prompt by typing ruby -v
Step 2: Install rubygems: Any version above 1.3.5 will work
Step 3: Install GNU : Install GNU for windows so that commands like make etc can work. You can download it from http://gnuwin32.sourceforge.net/packages/make.htm for windows. For Linux and Mac it will be already installed.
Step 4: Install JDK : Install JDK version 1.6.0_2 or higher. You can download it from http://www.oracle.com/technetwork/java/javase/downloads/index.html
Make sure you set JAVA_HOME and that JAVA_HOME/bin is on your path.
Major issues which may prompt are:
--If you get any "no such file to load -- something" messages while running the rake tasks or rhogen commands, this can usually be resolved by running '[sudo] gem install something'.
-- If your libintl3.dll is not loaded then download it by googling and put in bin folder.
Step 5 : You can install Rhodes in two ways
- Download it from git
- Download it as gem
I will prefer download it as gem. Just type on command prompt
gem install rhodes
Step 6: Install Simulator : Install the simulator of the phone for which you want to build application
1.) Blackberry : You can download the latest version of simulator from the following URL : https://www.blackberry.com/Downloads/entry.do?code=060AD92489947D410D897474079C1477
2.) Iphone: You can install it from apple website. But it will work on apple machine.
3.) Android : You can download the latest version of simulator from the following URL :
You are ready to create your first application.