7 Replies Latest reply on Feb 28, 2013 10:23 AM by Andre Pollard

    how can we generate uuid in Rhodes application?

      Now I run into a problem, I need to generate a UUID inside the application. I found in in RhoStudio folder, there is uuid-2.3.5 gem,




      I wonder if we can use it in the application.


      I tried the different way to add it in the app/lib folder, it seems rhodes app does not recognize that.


      Can anybody provide an insight?




        • Re: how can we generate uuid in Rhodes application?
          Jon Tara

          Those Gems are not part of the Rhodes runtime. They are part of the Rhodes compile-time environment. Rhodes uses Ruby at compile-time. Neither the Ruby nor the RubyGems are part of Rhodes.


          Rhodes has it's own Ruby interpreter which is embedded in the Rhodes Gem.


          You cannot use Gems in Rhodes applications. You need to use Rhodes extensions. Many Rhodes Gems can be converted to Rhodes extensions failrly easily. Others can require a lot of work.


          Please see the documentation on extending Rhodes.

            • Re: how can we generate uuid in Rhodes application?
              Yuriy Volyanskyy

              Is there a tutorial on generation UUID in Rhodes using uuidtools or other method?

                • Re: how can we generate uuid in Rhodes application?

                  Here is how to setup UUID generator (uuidtools) in Rhodes gem 3.4.2

                  This library is capable of generating unique UUID values based on current timestamp


                  First locate the directory:


                      [C:\MotorolaRhoMobileSuite2.1.1.7\ruby\lib\ruby\gems\1.9.1\gems\rhodes-3.4.2\lib\extensions], i will refer to this as EXT


                  We will need to put all the required files into EXT and/or its children...


                  1. Create directory [EXT\uuidtools]
                  2. Copy file [C:\MotorolaRhoMobileSuite2.1.1.7\ruby\lib\ruby\gems\1.9.1\gems\uuidtools-2.1.3\lib\uuidtools.rb] to [EXT\uuidtools\]
                  3. Create directory [EXT\uuidtools\uuidtools]
                  4. Copy file [C:\MotorolaRhoMobileSuite2.1.1.7\ruby\lib\ruby\gems\1.9.1\gems\uuidtools-2.1.3\lib\uuidtools\version.rb] to [EXT\uuidtools\uuidtools\]
                  5. Create directory [EXT\securerandom]
                  6. Copy file [C:\MotorolaRhoMobileSuite2.1.1.7\ruby\lib\ruby\gems\1.9.1\gems\uuidtools-2.1.3\lib\compat\securerandom.rb] to [EXT\securerandom\]
                  7. Copy file [C:\MotorolaRhoMobileSuite2.1.1.7\ruby\lib\ruby\gems\1.9.1\gems\rhodes-3.4.2\lib\extensions\digest-sha1\digest\sha1.rb] to [EXT\digest\]
                  8. Copy file [C:\MotorolaRhoMobileSuite2.1.1.7\ruby\lib\ruby\gems\1.9.1\gems\rhodes-3.4.2\lib\extensions\digest-md5\digest\md5.rb] to [EXT\digest\]
                  9. in your project build.yml ensure that these extensions are enabled:
                    • extensions: ["json", "net-http", "thread", "timeout", "uri", "digest" , "digest-sha1", "digest-md5", "uuidtools", "uuidtools-version", "securerandom"]
                  10. in your ruby controller or other ruby file that requires library add:
                    • require 'uuidtools'


                  an example call is as follows:


                      id = UUIDTools::UUID.timestamp_create

                      p id.to_s


                  the log file output of id.to_s should be similar to the following:


                  I 10/08/2012 14:59:00:617 000005dc                  APP| "37a0ffa4-117a-11e2-92dd-1119ebdb08c9"



                  Michael Kroeze

                    • Re: how can we generate uuid in Rhodes application?
                      Yuriy Volyanskyy

                      Thanks, Michael,

                      I think, Steve took the same approach. I was just hoping that it would also be possible to use MAC address in the generated UUID, in addition to timestamp.

                      Rhodes use MAC address when run on desktop (parsing ipconffig), but we couldn’t make it read MAC address from the device.


                      • Re: how can we generate uuid in Rhodes application?

                        Hi Michael,

                        i have followed the steps for including the extensions into the application and they work like a gem when running the app in the RhoSimulator.

                        however, when i run the app on a WM device, the app crashes after showing the splash screen, after which i can see the following in the log file:

                             RhoRuby| require_compiled: error: can not find digest


                        do i need to do something else to include the libraries when running on a device? i can see the files included in relevant folders under \Program Files\MyApplication\rho\lib\.


                        i am seeing the same behavior when trying to run on an Android device.




                        Message was edited by: Ameer Ilahi having looked further into this, the difference here are that i have RhoMobileSuite ver with rhodes- not sure if this should be the case however the following files are both empty (file size 0kb):            >> C:\MotorolaRhoMobileSuite2.2.1.12\ruby\lib\ruby\gems\1.9.1\gems\rhodes-\lib\extensions\digest-md5\digest\md5.rb            >> C:\MotorolaRhoMobileSuite2.2.1.12\ruby\lib\ruby\gems\1.9.1\gems\rhodes-\lib\extensions\digest-sha1\digest\sha1.rb if i remove  "digest" , "digest-sha1", "digest-md5" from the extensions list in the build.yml file, the application runs, however fails to generate the uuids (crashes on a WM6 device; logs an error in the RhoSimulator).

                          • Re: how can we generate uuid in Rhodes application?
                            Jon Tara

                            Any scheme that manages to create an ID that is unique to the device is going to be shot down by Apple. They have been clamping down on this further recently.


                            Unless you want to risk having your app pulled from the store once a unique ID is discovered, I'd suggest not doing this.


                            I think we need to use the new application-specific UUID provided by the SDK and live with the consequences. That is, if the user un-installs your app and reinstalls it, then it gets a new ID.


                            Rhodes needs to be updated to use the new ID (unless it has been already).


                            Just to be clear, the ID that is banned is called the UDID "unique device ID". UUID is just a generic term that means "universal unique ID", and is generally understood to mean a pseudo-universal unique ID (with some small possibility of collision.) Apple has made it clear that they will also reject any app that uses a UDID equivalent. e.g. any identifier that will uniquely identify the device, and that thus could be used to correlate identity of devices across different apps from different publishers. (There are ways to correlate among your own apps, and that is OK. You can use the keychain.)


                            Each iOS device as a UDID that never changes. Apple no longer allows apps to use a UDID to identify the device. The SDK provided an application-specific UUID as an alternative.

                    • Re: how can we generate uuid in Rhodes application?

                      Here is what i did, you should be able to change what encoding you like (sha1, sha2, etc)


                      in build.yml add



                        - json

                        - hmac

                        - digest

                        - digest-sha1


                      in rhoconfig.txt i created a var to hold uuid

                      my_wzp_id = ''


                      In my controller i set it here

                      require 'base64'

                      require 'hmac-sha1'

                      require 'time'

                      Rho::RhoConfig.my_wzp_id = HMAC::SHA1.new("my ramdom salt #{Time.now.strftime('%Y-%m-%d')}")


                      Access it