Monday, April 30, 2012

Using Rhohub to build Rhomobile applications targeting iOS (for Windows/Linux users and dummies)

1. Generate your developer certificate and provisioning profile

All iOS applications must be signed by a valid certificate, which you should get from Apple, before they can be run on an Apple device. For privacy, the signing certificate you upload to RhoHub is used only once and thrown away.

Windows or Linux

  1. Install OpenSSL if you don't have it (on Windows, OpenSSL is included in Git Bash).
  2. Follow the generating a certificate signing request instructions on the iOS developer portal.
  3. Execute the following commands to generate your certificate signing request, filling in your email address used in the development portal:
  4. openssl genrsa -out mykey.key 2048
    openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest -subj '/emailAddress=yourAddress@example.com, CN=John Doe, C=US'
  5. Upload the resulting certSigningRequest file to the developer portal.
  6. After the certificate has been generated, download the .cer file and use the following commands to convert it to the .p12 format. You will be prompted for an export password. This is a new password for this file and cannot be blank.
    openssl x509 -in developer_identity.cer -inform DER -out developer_identity.pem -outform PEM
    openssl pkcs12 -export -inkey mykey.key -in developer_identity.pem -out iphone_dev.p12
  7. Create a provisioning profile and associate your developer certificate with it and download it. Lets call it your_app.mobileprovision

2. Configure build.yml

Follow the instructions given at http://docs.rhomobile.com/rhodes/build#building-a-rhodes-application-for-iphoneipad
provisionprofile: E5931D39-CA68-48E4-A3AF-BB538E1C8CE6 
Here's how I found the UID associated with provision profile:
1. Use any binary file viewer. Eg. binary viewer for windows, ghex for linux to open your_app.mobileprovision.
2. Locate the tag UUID. It would look something like the following
<key>UUID</key>
<string>5349A91C-FABC-ABCD-BB5A-8D36B186XXXX</string>
This string is what goes into your provision profile.
codesignidentity: "iPhone Developer: John Smith (MF99RW67WY)"
Open the certificate - iphone_dev.p12. It has this information in the exact same format.

BundleIdentifier: com.johnsmithcompany.jsapp

Notice the app id in your provisioning portal. Should look like some random hex followed by com.yourcompany.app.blah. eg. G2GXEVYDX5.com.johnsmithcompany.jsapp

So, if you just copy everything other than the <hex><dot>, it should give your your bundle identifier.

3. Push to Rhohub

Sign up on Rhohub.com and create a project.
Now push your rhodes code to your project's git repository.

4. Build

Needless to say, select iOS in target device.
Select iphone_dev.p12 file to upload as the certificate, and enter the certificate password that you used while making the p12.
Select provisioning profile and give the same bundle identifier that you gave in your build.yml

Now press "build" and relax...

No comments: